def main(self): cmd = BundleImage(image=self.args['image'], arch=self.args['arch'], cert=self.args['cert'], privatekey=self.args['privatekey'], user=self.args['user'], destination=self.args.get('directory'), ec2cert=self.args['ec2cert'], image_type='machine', config=self.config) parts, manifest = cmd.main() cmd = UploadBundle(bucket=self.args['bucket'], manifest=manifest, acl='ec2-bundle-read', config=self.config, service=self.__walrus) manifest_loc = cmd.main() return manifest_loc
def bundle_and_upload_image(self, image, image_type, workdir, kernel_id=None, ramdisk_id=None): unique_bucket = self.args['bucket'] if image_type == 'machine': image_type_args = {'kernel': kernel_id, 'ramdisk': ramdisk_id} progressbar_label = 'Bundling image ' elif image_type == 'kernel': image_type_args = {'kernel': 'true'} progressbar_label = 'Bundling kernel ' if self.args.get('separate_buckets'): unique_bucket = ''.join([self.args['bucket'], '-kernel']) elif image_type == 'ramdisk': image_type_args = {'ramdisk': 'true'} progressbar_label = 'Bundling ramdisk ' if self.args.get('separate_buckets'): unique_bucket = ''.join([self.args['bucket'], '-ramdisk']) else: raise ValueError( "unrecognized image type: '{0}'".format(image_type)) cmd = BundleImage(config=self.config, image=image, arch=self.args['architecture'], cert=self.args['cert'], privatekey=self.args['privatekey'], ec2cert=self.args['ec2cert'], user=self.args['user'], destination=workdir, image_type=image_type, show_progress=self.args.get('show_progress', False), progressbar_label=progressbar_label, **image_type_args) __, manifest_path = cmd.main() if self.args.get('show_progress', False): print '-- Uploading {0} image --'.format(image_type) cmd = UploadBundle(config=self.config, service=self.__walrus, bucket=unique_bucket, manifest=manifest_path, acl='aws-exec-read', show_progress=self.args.get('show_progress', False)) manifest_loc = cmd.main() return manifest_loc
def __build_bundle_command(self, image_filename, image_size=None): bundle_args = ('prefix', 'destination', 'arch', 'privatekey', 'cert', 'ec2cert', 'user', 'kernel', 'ramdisk', 'block_device_mappings', 'productcodes', 'part_size', 'enc_key', 'enc_iv', 'show_progress') bundle_args_dict = dict((key, self.args.get(key)) for key in bundle_args) return BundleImage.from_other(self, image=image_filename, image_size=image_size, image_type='machine', **bundle_args_dict)
def bundle_and_upload_image(self, image, image_type, workdir, kernel_id=None, ramdisk_id=None): unique_bucket = self.args['bucket'] if image_type == 'machine': image_type_args = {'kernel': kernel_id, 'ramdisk': ramdisk_id} progressbar_label = 'Bundling image ' elif image_type == 'kernel': image_type_args = {'kernel': 'true'} progressbar_label = 'Bundling kernel ' if self.args.get('separate_buckets'): unique_bucket = ''.join([self.args['bucket'], '-kernel']) elif image_type == 'ramdisk': image_type_args = {'ramdisk': 'true'} progressbar_label = 'Bundling ramdisk ' if self.args.get('separate_buckets'): unique_bucket = ''.join([self.args['bucket'], '-ramdisk']) else: raise ValueError("unrecognized image type: '{0}'" .format(image_type)) cmd = BundleImage(config=self.config, image=image, arch=self.args['architecture'], cert=self.args['cert'], privatekey=self.args['privatekey'], ec2cert=self.args['ec2cert'], user=self.args['user'], destination=workdir, image_type=image_type, show_progress=self.args.get('show_progress', False), progressbar_label=progressbar_label, **image_type_args) __, manifest_path = cmd.main() if self.args.get('show_progress', False): print '-- Uploading {0} image --'.format(image_type) cmd = UploadBundle(config=self.config, service=self.__walrus, bucket=unique_bucket, manifest=manifest_path, acl='aws-exec-read', show_progress=self.args.get('show_progress', False)) manifest_loc = cmd.main() return manifest_loc
def main(self): if self.args.get('inherit'): self._inherit_metadata() image_file = ImageCreator(log=self.log, **self.args).run() try: image_args = self._filter_args_for_bundle_image() image_args.update(image=image_file, image_type='machine') self.log.info("bundling image: {0}".format(image_file)) return BundleImage(**image_args).main() finally: if os.path.exists(image_file): os.remove(image_file) os.rmdir(os.path.dirname(image_file))