[pkg-eucalyptus-commits] [SCM] managing cloud instances for Eucalyptus branch, master, updated. 3.0.0-alpha3-257-g1da8e3a
Garrett Holmstrom
gholms at fedoraproject.org
Sun Jun 16 02:31:21 UTC 2013
The following commit has been merged in the master branch:
commit 30f2bc6dc9c7c07f1f5a6e71d2c0e94db134fe95
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Thu May 9 14:11:50 2013 -0700
Fix line wrapping and bucket/prefix handling
Partially addresses TOOLS-168
diff --git a/bin/euca-delete-bundle b/bin/euca-delete-bundle
index 4e54d50..770502c 100755
--- a/bin/euca-delete-bundle
+++ b/bin/euca-delete-bundle
@@ -1,41 +1,6 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-# Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the
-# following disclaimer.
-#
-# Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the
-# following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-# Mitch Garnaat mgarnaat at eucalyptus.com
+#!/usr/bin/python -tt
import euca2ools.commands.bundle.deletebundle
if __name__ == '__main__':
euca2ools.commands.bundle.deletebundle.DeleteBundle.run()
-
diff --git a/bin/euca-download-bundle b/bin/euca-download-bundle
index a79ed25..35786dd 100755
--- a/bin/euca-download-bundle
+++ b/bin/euca-download-bundle
@@ -1,41 +1,6 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-# Software License Agreement (BSD License)
-#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
-# All rights reserved.
-#
-# Redistribution and use of this software in source and binary forms, with or
-# without modification, are permitted provided that the following conditions
-# are met:
-#
-# Redistributions of source code must retain the above
-# copyright notice, this list of conditions and the
-# following disclaimer.
-#
-# Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the
-# following disclaimer in the documentation and/or other
-# materials provided with the distribution.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-# Mitch Garnaat mgarnaat at eucalyptus.com
+#!/usr/bin/python -tt
import euca2ools.commands.bundle.downloadbundle
if __name__ == '__main__':
euca2ools.commands.bundle.downloadbundle.DownloadBundle.run()
-
diff --git a/euca2ools/commands/bundle/deletebundle.py b/euca2ools/commands/bundle/deletebundle.py
index e508e00..e4a873b 100644
--- a/euca2ools/commands/bundle/deletebundle.py
+++ b/euca2ools/commands/bundle/deletebundle.py
@@ -1,6 +1,6 @@
# Software License Agreement (BSD License)
#
-# Copyright (c) 2009-2011, Eucalyptus Systems, Inc.
+# Copyright (c) 2009-2013, Eucalyptus Systems, Inc.
# All rights reserved.
#
# Redistribution and use of this software in source and binary forms, with or
@@ -27,9 +27,6 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-# Mitch Garnaat mgarnaat at eucalyptus.com
from euca2ools.commands.bundle.helpers import download_files
from euca2ools.commands.bundle.helpers import get_manifest_keys
@@ -50,20 +47,21 @@ import time
class DeleteBundle(WalrusRequest):
- DESCRIPTION = 'Delete a previously-uploaded bundle.'
- ARGS = [Arg('-b', '--bucket', dest='bucket', metavar='BUCKET',
- required=True, help='Name of the bucket to delete from.'),
+ DESCRIPTION = 'Delete a previously-uploaded bundle'
+ ARGS = [Arg('-b', '--bucket', dest='bucket', metavar='BUCKET[/PREFIX]',
+ required=True,
+ help='location of the bundle to delete (required)'),
MutuallyExclusiveArgList(True,
- Arg('-m', '--manifest', dest='manifest_path', metavar='MANIFEST',
- help='Delete a bundle based on a local manifest file'),
+ Arg('-m', '--manifest', dest='manifest_path',
+ metavar='MANIFEST', help='''use a local manifest file to
+ figure out what to delete'''),
Arg('-p', '--prefix', dest='prefix',
- help=('Delete a bundle with a manifest in the bucket that '
- 'begins with a specific name (e.g. "fry" for '
- '"fry.manifest.xml")')),
+ help='''delete the bundle that begins with a specific
+ prefix (e.g. "fry" for "fry.manifest.xml")'''),
Arg('--delete-all-bundles', dest='delete_all',
action='store_true', help=argparse.SUPPRESS)),
Arg('--clear', dest='clear', action='store_true',
- help='Delete the entire bucket if possible')]
+ help='attempt to delete the bucket as well')]
def _delete_manifest_parts(self, manifest_keys, directory):
bucket = self.args.get('bucket')
@@ -75,7 +73,8 @@ class DeleteBundle(WalrusRequest):
def _delete_manifest_keys(self, manifest_keys):
bucket = self.args.get('bucket')
paths = [os.path.join(bucket, key) for key in manifest_keys]
- DeleteObject(paths=paths).main()
+ DeleteObject(paths=paths, service=self.service,
+ config=self.config).main()
def _delete_by_local_manifest(self):
manifest_path = self.args.get('manifest_path')
@@ -100,14 +99,17 @@ class DeleteBundle(WalrusRequest):
bucket = self.args.get('bucket')
directory = tempfile.mkdtemp()
try:
- manifest_keys = ["{0}.manifest.xml".format(self.args.get('prefix'))]
+ manifest_keys = ["{0}.manifest.xml".format(
+ self.args.get('prefix'))]
try:
download_files(bucket, manifest_keys, directory,
service=self.service, config=self.config)
except AWSError as err:
if err.code == 'NoSuchEntity':
- error = "manifest file '{0}' does not exist in bucket '{1}'."
- raise ArgumentError(error.format(manifest_keys[0], bucket))
+ error = ("manifest file '{0}' does not exist in bucket "
+ "'{1}'.")
+ raise ArgumentError(error.format(manifest_keys[0],
+ bucket))
else:
raise
self._delete_manifest_parts(manifest_keys, directory)
@@ -117,10 +119,12 @@ class DeleteBundle(WalrusRequest):
def _delete_all_bundles(self):
bucket = self.args.get('bucket')
- print >> sys.stderr, """All bundles in bucket '{0}' will be deleted.
-If this is not what you want, press Ctrl+C in the next 10 seconds""".format(bucket)
+ msg = ("All bundles in bucket '{0}' will be deleted! If this is not "
+ "what you want, press Ctrl+C in the next 10 seconds".format(
+ bucket))
+ print >> sys.stderr, msg
try:
- for _ in range(10):
+ for __ in range(10):
sys.stderr.write('.')
sys.stderr.flush()
time.sleep(1)
@@ -144,7 +148,7 @@ If this is not what you want, press Ctrl+C in the next 10 seconds""".format(buck
shutil.rmtree(directory)
def main(self):
- bucket = self.args.get('bucket')
+ bucket = self.args.get('bucket').split('/', 1)[0]
# Verify bucket existence
CheckBucket(bucket=bucket, service=self.service,
@@ -157,9 +161,9 @@ If this is not what you want, press Ctrl+C in the next 10 seconds""".format(buck
elif self.args.get('prefix'):
self._delete_by_prefix()
# Delete all bundles in the bucket
- elif self.args.get('delete_all') is True:
+ elif self.args.get('delete_all'):
self._delete_all_bundles()
- if self.args.get('clear') is True:
+ if self.args.get('clear'):
DeleteBucket(bucket=bucket, service=self.service,
config=self.config).main()
diff --git a/euca2ools/commands/bundle/downloadbundle.py b/euca2ools/commands/bundle/downloadbundle.py
index f96ceda..6fe1c69 100644
--- a/euca2ools/commands/bundle/downloadbundle.py
+++ b/euca2ools/commands/bundle/downloadbundle.py
@@ -27,9 +27,6 @@
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
-#
-# Author: Neil Soman neil at eucalyptus.com
-# Mitch Garnaat mgarnaat at eucalyptus.com
from euca2ools.commands.bundle.helpers import download_files
from euca2ools.commands.bundle.helpers import get_manifest_keys
@@ -46,15 +43,19 @@ import tempfile
class DownloadBundle(WalrusRequest):
- DESCRIPTION = 'Downloads a bundled image from a bucket.'
+ DESCRIPTION = ('Download a bundled image from the cloud\n\nYou must run '
+ 'euca-unbundle-image on the bundle you download to obtain '
+ 'the original image.')
ARGS = [Arg('-b', '--bucket', metavar='BUCKET', required=True,
- help='Name of the bucket to upload to.'),
+ help='bucket to download the bucket from (required)'),
MutuallyExclusiveArgList(
Arg('-m', '--manifest', dest='manifest_path', metavar='FILE',
- help='Path to local manifest file for bundled image.'),
+ help='''use a local manifest file to figure out what to
+ download'''),
Arg('-p', '--prefix', metavar='PREFIX',
- help='Prefix used to identify the image in the bucket')),
- Arg('-d', '--directory', metavar='DIRECTORY',
+ help='''download the bundle that begins with a specific
+ prefix (e.g. "fry" for "fry.manifest.xml")''')),
+ Arg('-d', '--directory', metavar='DIR',
help='The directory to download the parts to.')]
def _download_parts(self, manifests, directory):
@@ -101,7 +102,7 @@ class DownloadBundle(WalrusRequest):
self._download_parts(manifest_keys, directory)
def main(self):
- bucket = self.args.get('bucket')
+ bucket = self.args.get('bucket').split('/', 1)[0]
CheckBucket(bucket=bucket, service=self.service,
config=self.config).main()
diff --git a/euca2ools/commands/bundle/helpers.py b/euca2ools/commands/bundle/helpers.py
index 0c35015..e49542d 100644
--- a/euca2ools/commands/bundle/helpers.py
+++ b/euca2ools/commands/bundle/helpers.py
@@ -75,6 +75,7 @@ def get_manifest_keys(bucket, prefix=None, **kwargs):
manifests.append(key)
return manifests
+
def download_files(bucket, keys, directory, **kwargs):
"""Download manifests from a Walrus bucket to a local directory.
:param bucket: The bucket to download manifests from.
--
managing cloud instances for Eucalyptus
More information about the pkg-eucalyptus-commits
mailing list