[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:06 UTC 2013
The following commit has been merged in the master branch:
commit 00b4b731794a7132cfb48e0fb6b15fa5c3f71bd5
Author: Garrett Holmstrom <gholms at fedoraproject.org>
Date: Tue Apr 23 10:30:19 2013 -0700
Move BundleImage over to FileTransferProgressBarMixin
diff --git a/euca2ools/commands/bundle/bundle.py b/euca2ools/commands/bundle/bundle.py
index ae00179..c29cdc7 100644
--- a/euca2ools/commands/bundle/bundle.py
+++ b/euca2ools/commands/bundle/bundle.py
@@ -64,15 +64,15 @@ class Bundle(object):
@classmethod
def create_from_image(cls, image_filename, part_prefix, part_size=None,
- show_progress=False):
+ progressbar=None):
new_bundle = cls()
new_bundle.__create_from_image(image_filename, part_prefix,
part_size=part_size,
- show_progress=show_progress)
+ progressbar=progressbar)
return new_bundle
def __create_from_image(self, image_filename, part_prefix, part_size=None,
- show_progress=False):
+ progressbar=None):
if part_size is None:
part_size = self.DEFAULT_PART_SIZE
with self._lock:
@@ -139,7 +139,7 @@ class Bundle(object):
# Drive everything by feeding tar
with open(image_filename) as image:
with os.fdopen(tar_out_pipe_in, 'w') as tar_input:
- _write_tarball(image, tar_input, show_progress=show_progress)
+ _write_tarball(image, tar_input, progressbar=progressbar)
writer_thread.join()
overall_digest = digest_pipe_out.recv()
@@ -161,22 +161,16 @@ class Bundle(object):
### BUNDLE CREATION ###
-def _write_tarball(infile, outfile, show_progress=False):
+def _write_tarball(infile, outfile, progressbar=None):
tar_thread = threading.Thread(target=_add_fileobj_to_tarball,
args=(infile, outfile))
tar_thread.start()
- if show_progress:
- import progressbar
- widgets = [progressbar.Percentage(), ' ', progressbar.Bar(marker='='),
- ' ', progressbar.FileTransferSpeed(), ' ',
- progressbar.ETA()]
- bar = progressbar.ProgressBar(maxval=os.path.getsize(infile.name),
- widgets=widgets)
- bar.start()
+ if progressbar is not None:
+ progressbar.start()
while tar_thread.is_alive():
- bar.update(infile.tell())
+ progressbar.update(infile.tell())
time.sleep(0.01)
- bar.finish()
+ progressbar.finish()
tar_thread.join()
diff --git a/euca2ools/commands/bundle/bundleimage.py b/euca2ools/commands/bundle/bundleimage.py
index 486a276..389a38c 100644
--- a/euca2ools/commands/bundle/bundleimage.py
+++ b/euca2ools/commands/bundle/bundleimage.py
@@ -42,6 +42,7 @@ import os.path
from requestbuilder import Arg
from requestbuilder.command import BaseCommand
from requestbuilder.exceptions import ArgumentError
+from requestbuilder.mixins import FileTransferProgressBarMixin
from requestbuilder.util import set_userregion
import subprocess
import tempfile
@@ -62,7 +63,7 @@ def manifest_block_device_mappings(mappings_as_str):
return mappings
-class BundleImage(BaseCommand):
+class BundleImage(BaseCommand, FileTransferProgressBarMixin):
DESCRIPTION = 'Prepare an image for uploading to a cloud'
SUITE = Euca2ools
ARGS = [Arg('-i', '--image', metavar='FILE', required=True,
@@ -99,7 +100,6 @@ class BundleImage(BaseCommand):
Arg('--productcodes', metavar='CODE1,CODE2,...',
type=delimited_list(','),
help='comma-separated list of product codes'),
- Arg('--progress', action='store_true', help='show progress'),
Arg('--batch', action='store_true', help=argparse.SUPPRESS),
Arg('--part-size', type=filesize, default=10485760, # 10m
help=argparse.SUPPRESS),
@@ -168,9 +168,11 @@ class BundleImage(BaseCommand):
path_prefix = os.path.join(tempdir, prefix)
self.log.debug('bundle path prefix: %s', path_prefix)
+ bar = self.get_progressbar(label='Bundling image',
+ maxval=os.path.getsize(self.args['image']))
bundle = Bundle.create_from_image(
self.args['image'], path_prefix, part_size=self.args['part_size'],
- show_progress=self.args['progress'])
+ progressbar=bar)
manifest = self.generate_manifest_xml(bundle)
manifest_filename = path_prefix + '.manifest.xml'
with open(manifest_filename, 'w') as manifest_file:
--
managing cloud instances for Eucalyptus
More information about the pkg-eucalyptus-commits
mailing list