def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: image_utils.fetch_verify_image(context, image_service, image_id, tmp) image_utils.fetch_to_raw(context, image_service, image_id, tmp, self.configuration.volume_dd_blocksize, size=volume['size'])
def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self.client.delete(volume.name) # convert and store into sheepdog image_utils.convert_image(tmp, self.client.local_path(volume), "raw") self.client.resize(volume.name, volume.size)
def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self.client.delete(volume.name) # convert and store into sheepdog image_utils.convert_image(tmp, self.local_path(volume), 'raw') self.client.resize(volume.name, volume.size)
def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self._delete(volume) # convert and store into sheepdog image_utils.convert_image(tmp, 'sheepdog:%s' % volume['name'], 'raw') self._resize(volume)
def copy_image_to_volume(self, context, volume, image_service, image_id): # use the image_conversion_dir as a temporary place to save the image conversion_dir = CONF.image_conversion_dir self._ensure_dir_exists(conversion_dir) with tempfile.NamedTemporaryFile(dir=conversion_dir) as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp.name) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self._delete(volume) # convert and store into sheepdog image_utils.convert_image(tmp, 'sheepdog:%s' % volume['name'], 'raw') self._resize(volume)
def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self.client.delete(volume.name) # convert and store into sheepdog image_utils.convert_image( tmp, 'sheepdog:%(addr)s:%(port)d:%(name)s' % { 'addr': CONF.sheepdog_store_address, 'port': CONF.sheepdog_store_port, 'name': volume['name'] }, 'raw') self.client.resize(volume.name, volume.size)
def copy_image_to_volume(self, context, volume, image_service, image_id): with image_utils.temporary_file() as tmp: # (wenhao): we don't need to convert to raw for sheepdog. image_utils.fetch_verify_image(context, image_service, image_id, tmp) # remove the image created by import before this function. # see volume/drivers/manager.py:_create_volume self.client.delete(volume.name) # convert and store into sheepdog image_utils.convert_image( tmp, 'sheepdog:%(addr)s:%(port)d:%(name)s' % { 'addr': CONF.sheepdog_store_address, 'port': CONF.sheepdog_store_port, 'name': volume['name']}, 'raw') self.client.resize(volume.name, volume.size)
def copy_image_to_volume(self, context, volume, image_service, image_id): """Fetch the image from image_service and write it to the volume.""" img_cache_volume = {'name': 'img-%s' % image_id} img_cache_snapshot = {'volume_name': img_cache_volume['name'], 'name': 'snap'} if self._list_snapshots(volume): # If the volume has snapshots, there is no efficient way to replace # the contents. Do things the inefficient way. image_utils.fetch_to_raw(context, image_service, image_id, self.local_path(volume), self.configuration.volume_dd_blocksize, size=volume['size']) else: if not self.snapshot_exists(img_cache_snapshot): with image_utils.temporary_file() as tmp: image_utils.fetch_verify_image(context, image_service, image_id, tmp) qemu_info = image_utils.qemu_img_info(tmp) virtual_size_gb = math.ceil( qemu_info.virtual_size / (1024.0 ** 3)) img_cache_volume['size'] = virtual_size_gb self.create_volume(img_cache_volume) image_utils.convert_image( tmp, self.local_path(img_cache_volume), 'raw', None, sparse=64 * 1024) self.create_snapshot(img_cache_snapshot) self.delete_volume(volume) self.create_volume_from_snapshot(volume, img_cache_snapshot) self.extend_volume(volume, volume['size'])