Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:sschapiro:openstack:upstream
euca2ools
327-fix-bundling-to-ec2.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 327-fix-bundling-to-ec2.patch of Package euca2ools
Author: Scott Moser <smoser@ubuntu.com> Last-Update: 2011-01-14 Upstream: r327 Description: cherry pick from 327 (LP: #665667) ------------------------------------------------------------ revno: 327 committer: root <root@buildserver> branch nick: euca2ools-main timestamp: Wed 2010-12-15 17:57:40 -0800 message: fixed sha1 generation for image/vol bundling. pipelined === modified file 'bin/euca-bundle-image' --- a/bin/euca-bundle-image +++ b/bin/euca-bundle-image @@ -212,12 +212,11 @@ print 'Invalid ec2cert' sys.exit(1) - (image_size, sha_image_digest) = euca.check_image(image_path, - destination_path) + image_size = euca.check_image(image_path, destination_path) if not prefix: prefix = euca.get_relative_filename(image_path) try: - tgz_file = euca.tarzip_image(prefix, image_path, + (tgz_file, sha_tar_digest) = euca.tarzip_image(prefix, image_path, destination_path) except NotFoundError: sys.exit(1) @@ -247,7 +246,7 @@ target_arch, image_size, bundled_size, - sha_image_digest, + sha_tar_digest, user, kernel, ramdisk, --- a/bin/euca-bundle-vol +++ b/bin/euca-bundle-vol @@ -430,12 +430,11 @@ cleanup(image_path) sys.exit(1) - (image_size, sha_image_digest) = euca.check_image(image_path, - destination_path) + image_size = euca.check_image(image_path, destination_path) if not prefix: prefix = euca.get_relative_filename(image_path) try: - tgz_file = euca.tarzip_image(prefix, image_path, + (tgz_file, sha_tar_digest) = euca.tarzip_image(prefix, image_path, destination_path) except NotFoundError: sys.exit(1) @@ -460,7 +459,7 @@ target_arch, image_size, bundled_size, - sha_image_digest, + sha_tar_digest, user, kernel, ramdisk, --- a/euca2ools/euca2ools/__init__.py +++ b/euca2ools/euca2ools/__init__.py @@ -43,6 +43,7 @@ from M2Crypto import BN, EVP, RSA, X509 from binascii import hexlify, unhexlify from subprocess import * +import subprocess import platform import urllib import re @@ -716,7 +717,7 @@ number_parts += 1 bytes_read = 0 for i in range(0, number_parts, 1): - filename = '%s.%d' % (file, i) + filename = '%s.%02d' % (file, i) part_digest = sha() file_part = open(filename, 'wb') print 'Part:', self.get_relative_filename(filename) @@ -744,13 +745,7 @@ image_size = os.path.getsize(image_file) if self.debug: print 'Image Size:', image_size, 'bytes' - in_file = open(image_file, 'rb') - sha_image = sha() - buf = in_file.read(IMAGE_IO_CHUNK) - while buf: - sha_image.update(buf) - buf = in_file.read(IMAGE_IO_CHUNK) - return (image_size, hexlify(sha_image.digest())) + return image_size def tarzip_image( self, @@ -760,25 +755,35 @@ ): Util().check_prerequisite_command('tar') - print 'Tarring image' - tar_file = '%s.tar.gz' % os.path.join(path, prefix) - outfile = open(tar_file, 'wb') - file_path = self.get_file_path(file) + targz = '%s.tar.gz' % os.path.join(path, prefix) + targzfile = open(targz, 'w') + + # make process pipes tar_cmd = ['tar', 'ch', '-S'] + file_path = self.get_file_path(file) if file_path: tar_cmd.append('-C') tar_cmd.append(file_path) tar_cmd.append(self.get_relative_filename(file)) else: tar_cmd.append(file) - p1 = Popen(tar_cmd, stdout=PIPE) - p2 = Popen(['gzip'], stdin=p1.stdout, stdout=outfile) - p2.communicate() - outfile.close - if os.path.getsize(tar_file) <= 0: - print 'Could not tar image' + tarproc = subprocess.Popen(tar_cmd, stdout=subprocess.PIPE) + zipproc = subprocess.Popen(['gzip'], stdin=subprocess.PIPE, stdout=targzfile) + + # pass tar output to digest and gzip + sha_image = sha() + buf=os.read(tarproc.stdout.fileno(), 8196) + while buf: + zipproc.stdin.write(buf) + sha_image.update(buf) + buf=os.read(tarproc.stdout.fileno(), 8196) + + zipproc.stdin.close(); + targzfile.close() + if os.path.getsize(targz) <= 0: + print 'Could not tar/compress image' raise CommandFailed - return tar_file + return (targz, hexlify(sha_image.digest())) def hexToBytes(self, hexString): bytes = []
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor