def main(self): if self.args.get('check_cert'): self.check_certificate(self.args['iam_service'], self.args['iam_auth']) if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], self.args['prefix']) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, self.args['prefix']) self.log.debug('bundle path prefix: %s', path_prefix) # First create the bundle digest, partinfo = self.create_bundle(path_prefix) # All done; now build the manifest and write it to disk manifest = self.build_manifest(digest, partinfo) manifest_filename = '{0}.manifest.xml'.format(path_prefix) with open(manifest_filename, 'w') as manifest_file: manifest.dump_to_file(manifest_file, self.args['privatekey'], self.args['cert'], self.args['ec2cert']) # Then we just inform the caller of all the files we wrote. # Manifests are returned in a tuple for future expansion, where we # bundle for more than one region at a time. return (part.filename for part in partinfo), (manifest_filename,)
def main(self): if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], self.args['prefix']) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, self.args['prefix']) self.log.debug('bundle path prefix: %s', path_prefix) # First create the bundle digest, partinfo = self.create_bundle(path_prefix) # All done; now build the manifest and write it to disk manifest = self.build_manifest(digest, partinfo) manifest_filename = '{0}.manifest.xml'.format(path_prefix) with open(manifest_filename, 'w') as manifest_file: manifest.dump_to_file(manifest_file, self.args['privatekey'], self.args['cert'], self.args['ec2cert']) # Then we just inform the caller of all the files we wrote. # Manifests are returned in a tuple for future expansion, where we # bundle for more than one region at a time. return (part.filename for part in partinfo), (manifest_filename, )
def main(self): bucket = self.args.get('bucket').split('/', 1)[0] CheckBucket(bucket=bucket, service=self.service, config=self.config).main() directory = self.args.get('directory') or mkdtemp_for_large_files() if not os.path.isdir(directory): raise ArgumentError( "location '{0}' is either not a directory or does not exist." .format(directory)) if self.args.get('manifest_path'): self._download_by_local_manifest(directory) else: self._download_by_prefix(directory) print "Bundle downloaded to '{0}'".format(directory)
def main(self): if not self.args.get('kernel') or not self.args.get('ramdisk'): self.ensure_kernel_reg_privs() if self.args.get('directory'): workdir = self.args['directory'] should_delete_workdir = False else: workdir = mkdtemp_for_large_files() self.log.debug('created working directory %s', workdir) should_delete_workdir = True tarball_path = self.get_tarball(workdir=workdir) image_ids = self.bundle_and_register_all(workdir, tarball_path) if should_delete_workdir: shutil.rmtree(workdir) return image_ids
def main(self): if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], self.args['prefix']) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, self.args['prefix']) self.log.debug('bundle path prefix: %s', path_prefix) key_prefix = self.get_bundle_key_prefix() self.ensure_dest_bucket_exists() # First create the bundle and upload it to the server digest, partinfo = self.create_and_upload_bundle( path_prefix, key_prefix) # All done; now build the manifest, write it to disk, and upload it. manifest = self.build_manifest(digest, partinfo) manifest_filename = '{0}.manifest.xml'.format(path_prefix) with open(manifest_filename, 'w') as manifest_file: manifest.dump_to_file(manifest_file, self.args['privatekey'], self.args['cert'], self.args['ec2cert']) manifest_dest = key_prefix + os.path.basename(manifest_filename) self.upload_bundle_file(manifest_filename, manifest_dest, show_progress=self.args.get('show_progress')) if not self.args.get('preserve_bundle', False): os.remove(manifest_filename) # Then we just inform the caller of all the files we wrote. # Manifests are returned in a tuple for future expansion, where we # bundle for more than one region at a time. return { 'parts': tuple({ 'filename': part.filename, 'key': (key_prefix + os.path.basename(part.filename)) } for part in manifest.image_parts), 'manifests': ({ 'filename': manifest_filename, 'key': manifest_dest }, ) }
def main(self): if self.args.get('check_cert'): self.check_certificate(self.args['iam_service'], self.args['iam_auth']) if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], self.args['prefix']) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, self.args['prefix']) self.log.debug('bundle path prefix: %s', path_prefix) key_prefix = self.get_bundle_key_prefix() self.ensure_dest_bucket_exists() # First create the bundle and upload it to the server digest, partinfo = self.create_and_upload_bundle(path_prefix, key_prefix) # All done; now build the manifest, write it to disk, and upload it. manifest = self.build_manifest(digest, partinfo) manifest_filename = '{0}.manifest.xml'.format(path_prefix) with open(manifest_filename, 'w') as manifest_file: manifest.dump_to_file(manifest_file, self.args['privatekey'], self.args['cert'], self.args['ec2cert']) manifest_dest = key_prefix + os.path.basename(manifest_filename) self.upload_bundle_file(manifest_filename, manifest_dest, show_progress=self.args.get('show_progress')) if not self.args.get('preserve_bundle', False): os.remove(manifest_filename) # Then we just inform the caller of all the files we wrote. # Manifests are returned in a tuple for future expansion, where we # bundle for more than one region at a time. return {'parts': tuple({'filename': part.filename, 'key': (key_prefix + os.path.basename(part.filename))} for part in manifest.image_parts), 'manifests': ({'filename': manifest_filename, 'key': manifest_dest},)}
def main(self): prefix = (self.args.get('prefix') or os.path.basename(self.args['image'])) if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], prefix) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, prefix) self.log.debug('bundle path prefix: %s', path_prefix) label = self.args.get('progressbar_label', 'Bundling image') pbar = self.get_progressbar(label=label, maxval=os.path.getsize(self.args['image'])) bundle = Bundle.create_from_image( self.args['image'], path_prefix, part_size=self.args.get('part_size'), progressbar=pbar) manifest = self.generate_manifest_xml(bundle) manifest_filename = path_prefix + '.manifest.xml' with open(manifest_filename, 'w') as manifest_file: manifest_file.write(manifest) return (part['path'] for part in bundle.parts), manifest_filename
def main(self): prefix = (self.args.get('prefix') or os.path.basename(self.args['image'])) if self.args.get('destination'): path_prefix = os.path.join(self.args['destination'], prefix) if not os.path.exists(self.args['destination']): os.mkdir(self.args['destination']) else: tempdir = mkdtemp_for_large_files(prefix='bundle-') path_prefix = os.path.join(tempdir, prefix) self.log.debug('bundle path prefix: %s', path_prefix) label = self.args.get('progressbar_label', 'Bundling image') pbar = self.get_progressbar(label=label, maxval=os.path.getsize(self.args['image'])) bundle = Bundle.create_from_image(self.args['image'], path_prefix, part_size=self.args.get('part_size'), progressbar=pbar) manifest = self.generate_manifest_xml(bundle) manifest_filename = path_prefix + '.manifest.xml' with open(manifest_filename, 'w') as manifest_file: manifest_file.write(manifest) return (part['path'] for part in bundle.parts), manifest_filename