def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" LOG.error('begin time of COPY_VOLUME_TO_IMAGE is %s' % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) container_format = image_meta.get('container_format') file_name = image_meta.get('id') full_url = None if container_format in ['fs_vgw_url', 'vcloud_vgw_url', 'aws_vgw_url']: LOG.debug('get the vgw url') vgw_url = CONF.vgw.vgw_url.get(container_format) if vgw_url: full_url = vgw_url + '/' + file_name image_utils.upload_volume_to_vgw(context, image_service, image_meta, self.local_path(volume), volume, full_url) #create a empty file to glance with image_utils.temporary_file() as tmp: image_utils.upload_volume(context, image_service, image_meta, tmp) fileutils.delete_if_exists(tmp) LOG.error('end time of COPY_VOLUME_TO_IMAGE is %s' % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) else: image_utils.upload_volume(context, image_service, image_meta, self.local_path(volume))
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" LOG.error('begin time of COPY_VOLUME_TO_IMAGE is %s' %(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) container_format=image_meta.get('container_format') file_name=image_meta.get('id') full_url=None if container_format in ['fs_vgw_url','vcloud_vgw_url','aws_vgw_url']: LOG.debug('get the vgw url') vgw_url = CONF.vgw.vgw_url.get(container_format) if vgw_url: full_url=vgw_url+'/'+file_name image_utils.upload_volume_to_vgw(context, image_service, image_meta, self.local_path(volume), volume, full_url) #create a empty file to glance with image_utils.temporary_file() as tmp: image_utils.upload_volume(context, image_service, image_meta, tmp) fileutils.delete_if_exists(tmp) LOG.error('end time of COPY_VOLUME_TO_IMAGE is %s' %(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) else: image_utils.upload_volume(context, image_service, image_meta, self.local_path(volume))
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" # begin added by liuling LOG.error('begin time of COPY_VOLUME_TO_IMAGE is %s' % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) container_format = image_meta.get('container_format') file_name = image_meta.get('id') image_name = image_meta.get('name') full_url = None if container_format == 'vgw_url': LOG.debug('get the vgw url') #vgw_url = CONF.vgw.vgw_url.get(container_format) kwargs = { 'auth_url': CONF.keystone_authtoken.keystone_auth_url, 'tenant_name': CONF.keystone_authtoken.tenant_name, 'username': CONF.keystone_authtoken.user_name, 'password': CONF.keystone_authtoken.admin_password, 'insecure': True } keystoneclient = kc.Client(**kwargs) vgw_url = self._get_management_url(keystoneclient, image_name, service_type='v2v') if vgw_url: full_url = vgw_url + '/' + file_name image_utils.upload_volume_to_vgw(context, image_service, image_meta, self.local_path(volume), volume, full_url) #create a empty file to glance with image_utils.temporary_file() as tmp: image_utils.upload_volume(context, image_service, image_meta, tmp) fileutils.delete_if_exists(tmp) LOG.error('end time of COPY_VOLUME_TO_IMAGE is %s' % (time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) # end added by liuling else: image_utils.upload_volume(context, image_service, image_meta, self.local_path(volume))
def copy_volume_to_image(self, context, volume, image_service, image_meta): """Copy the volume to the specified image.""" LOG.error('begin time of COPY_VOLUME_TO_IMAGE is %s' %(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) container_format=image_meta.get('container_format') file_name=image_meta.get('id') image_name = image_meta.get('name') full_url=None if container_format == 'vgw_url': LOG.debug('get the vgw url') #vgw_url = CONF.vgw.vgw_url.get(container_format) kwargs = { 'auth_url': CONF.keystone_authtoken.keystone_auth_url, 'tenant_name':CONF.keystone_authtoken.tenant_name, 'username': CONF.keystone_authtoken.user_name, 'password': CONF.keystone_authtoken.admin_password, 'insecure': True } keystoneclient = kc.Client(**kwargs) vgw_url = self._get_management_url(keystoneclient,image_name, service_type='v2v') if vgw_url: full_url=vgw_url+'/'+file_name image_utils.upload_volume_to_vgw(context, image_service, image_meta, self.local_path(volume), volume, full_url) #create a empty file to glance with image_utils.temporary_file() as tmp: image_utils.upload_volume(context, image_service, image_meta, tmp) fileutils.delete_if_exists(tmp) LOG.error('end time of COPY_VOLUME_TO_IMAGE is %s' %(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))) else: image_utils.upload_volume(context, image_service, image_meta, self.local_path(volume))