def download_bundle_to_dir(self, manifest, dest_dir, s3_service): parts = self.map_bundle_parts_to_s3paths(manifest) for part, part_s3path in parts: part.filename = os.path.join(dest_dir, os.path.basename(part_s3path)) self.log.info('downloading part %s to %s', part_s3path, part.filename) req = GetObject( config=self.config, service=s3_service, source=part_s3path, dest=part.filename, show_progress=self.args.get('show_progress', False)) response = req.main() self.__check_part_sha1(part, part_s3path, response) manifest_s3path = self.get_manifest_s3path() if manifest_s3path: # Can't download a manifest if we're using a local one manifest_dest = os.path.join(dest_dir, os.path.basename(manifest_s3path)) self.log.info('downloading manifest %s to %s', manifest_s3path, manifest_dest) req = GetObject( config=self.config, service=s3_service, source=manifest_s3path, dest=manifest_dest, show_progress=self.args.get('show_progress', False)) req.main() return manifest_dest return None
def download_bundle_to_dir(self, manifest, dest_dir, s3_service): parts = self.map_bundle_parts_to_s3paths(manifest) for part, part_s3path in parts: part.filename = os.path.join(dest_dir, os.path.basename(part_s3path)) self.log.info('downloading part %s to %s', part_s3path, part.filename) req = GetObject(config=self.config, service=s3_service, source=part_s3path, dest=part.filename, show_progress=self.args.get( 'show_progress', False)) response = req.main() self.__check_part_sha1(part, part_s3path, response) manifest_s3path = self.get_manifest_s3path() if manifest_s3path: # Can't download a manifest if we're using a local one manifest_dest = os.path.join(dest_dir, os.path.basename(manifest_s3path)) self.log.info('downloading manifest %s to %s', manifest_s3path, manifest_dest) req = GetObject(config=self.config, service=s3_service, source=manifest_s3path, dest=manifest_dest, show_progress=self.args.get( 'show_progress', False)) req.main() return manifest_dest return None
def fetch_manifest(self, s3_service, privkey_filename=None): if self.args.get('local_manifest'): _assert_is_file(self.args['local_manifest'], 'manifest') return euca2ools.bundle.manifest.BundleManifest.read_from_file( self.args['local_manifest'], privkey_filename=privkey_filename) # It's on the server, so do things the hard way manifest_s3path = self.get_manifest_s3path() with tempfile.TemporaryFile() as manifest_tempfile: self.log.info('reading manifest from %s', manifest_s3path) req = GetObject(config=self.config, service=s3_service, source=manifest_s3path, dest=manifest_tempfile) try: req.main() except AWSError as err: if err.status_code == 404: self.log.debug('failed to fetch manifest', exc_info=True) raise ValueError("manifest '{0}' does not exist on the " "server".format(manifest_s3path)) raise manifest_tempfile.flush() manifest_tempfile.seek(0) return euca2ools.bundle.manifest.BundleManifest.read_from_fileobj( manifest_tempfile, privkey_filename=privkey_filename)
def download_bundle_to_fileobj(self, manifest, fileobj, s3_service): # We can skip downloading the manifest since we're just writing all # parts to a file object. parts = self.map_bundle_parts_to_s3paths(manifest) for part, part_s3path in parts: self.log.info('downloading part %s', part_s3path) req = GetObject( config=self.config, service=s3_service, source=part_s3path, dest=fileobj, show_progress=self.args.get('show_progress', False)) response = req.main() self.__check_part_sha1(part, part_s3path, response)
def download_bundle_to_fileobj(self, manifest, fileobj, s3_service): # We can skip downloading the manifest since we're just writing all # parts to a file object. parts = self.map_bundle_parts_to_s3paths(manifest) for part, part_s3path in parts: self.log.info('downloading part %s', part_s3path) req = GetObject(config=self.config, service=s3_service, source=part_s3path, dest=fileobj, show_progress=self.args.get( 'show_progress', False)) response = req.main() self.__check_part_sha1(part, part_s3path, response)