def run(self, **kwargs): """:returns: dictionary {<source-volume-id>: <destination-volume>}""" if self._is_nfs_shared(): mysql_connector.dump_db( self.dst_cloud, self.dst_cloud.cloud_config.storage.db_name) new_volumes = {} volumes = self.get_cinder_volumes(**kwargs) volumes = [v['volume'] for v in volumes.itervalues()] view = VolumeMigrationView(volumes) view.initial_message() for i, src_volume in enumerate(volumes): view.before_migration(i, src_volume) LOG.info("Checking if volume '%s' already present in destination", volume_name(src_volume)) dst_cinder = self.dst_cloud.resources[utils.STORAGE_RESOURCE] dst_volume = dst_cinder.get_migrated_volume(src_volume['id']) if dst_volume is not None: LOG.info( "Volume '%s' is already present in destination " "cloud, skipping", src_volume['id']) else: try: dst_volume = self.migrate_func(src_volume) except (plugins.base.VolumeObjectNotFoundError, retrying.TimeoutExceeded, exception.TenantNotPresentInDestination, cinder_exceptions.ClientException, copy_mechanisms.CopyFailed, copy_engines_base.NotEnoughSpace, mysql_connector.MySQLError) as e: LOG.warning("%(error)s, volume %(name)s will be skipped", { 'error': e.message, 'name': volume_name(src_volume) }) dst_volume = dst_cinder.get_migrated_volume( src_volume['id']) if dst_volume is not None: msg = ("Removing volume {name} from destination " "since it didn't migrate properly".format( name=volume_name(dst_volume))) LOG.info(msg) self.delete_volume(dst_volume) finally: if dst_volume is not None: self.dst_cinder_backend.cleanup( self.cloud, dst_volume.id) view.after_migration(i, src_volume) new_volumes[src_volume['id']] = dst_volume return new_volumes
def run(self, **kwargs): """:returns: dictionary {<source-volume-id>: <destination-volume>}""" if self._is_nfs_shared(): mysql_connector.dump_db( self.dst_cloud, self.dst_cloud.cloud_config.storage.db_name) new_volumes = {} volumes = self.get_cinder_volumes(**kwargs) volumes = [v['volume'] for v in volumes.itervalues()] view = VolumeMigrationView(volumes) view.initial_message() for i, src_volume in enumerate(volumes): view.before_migration(i, src_volume) LOG.info("Checking if volume '%s' already present in destination", volume_name(src_volume)) dst_cinder = self.dst_cloud.resources[utils.STORAGE_RESOURCE] dst_volume = dst_cinder.get_migrated_volume(src_volume['id']) if dst_volume is not None: LOG.info("Volume '%s' is already present in destination " "cloud, skipping", src_volume['id']) else: try: dst_volume = self.migrate_func(src_volume) except (plugins.base.VolumeObjectNotFoundError, retrying.TimeoutExceeded, exception.TenantNotPresentInDestination, cinder_exceptions.ClientException, copy_mechanisms.CopyFailed, copy_engines_base.NotEnoughSpace, mysql_connector.MySQLError) as e: LOG.warning("%(error)s, volume %(name)s will be skipped", {'error': e.message, 'name': volume_name(src_volume)}) dst_volume = dst_cinder.get_migrated_volume( src_volume['id']) if dst_volume is not None: msg = ("Removing volume {name} from destination " "since it didn't migrate properly".format( name=volume_name(dst_volume))) LOG.info(msg) self.delete_volume(dst_volume) finally: if dst_volume is not None: self.dst_cinder_backend.cleanup(self.cloud, dst_volume.id) view.after_migration(i, src_volume) new_volumes[src_volume['id']] = dst_volume return new_volumes
def __init__(self, resources, position, config): self.resources = resources self.position = position self.config = config self.cloud_config = self.make_cloud_config(self.config, self.position) self.init_resources(self.cloud_config) self.hosts_with_bbcp = set() if self.cloud_config.mysqldump.dump_all_databases: mysql_connector.dump_db(self)