Beispiel #1
0
 def _live_migrate(self, context, instance, scheduler_hint,
                   block_migration, disk_over_commit):
     destination = scheduler_hint.get("host")
     try:
         live_migrate.execute(context, instance, destination,
                          block_migration, disk_over_commit)
     except (exception.NoValidHost,
             exception.ComputeServiceUnavailable,
             exception.InvalidHypervisorType,
             exception.InvalidCPUInfo,
             exception.UnableToMigrateToSelf,
             exception.DestinationHypervisorTooOld,
             exception.InvalidLocalStorage,
             exception.InvalidSharedStorage,
             exception.HypervisorUnavailable,
             exception.InstanceNotRunning,
             exception.MigrationPreCheckError) as ex:
         with excutils.save_and_reraise_exception():
             # TODO(johngarbutt) - eventually need instance actions here
             request_spec = {'instance_properties': {
                 'uuid': instance['uuid'], },
             }
             scheduler_utils.set_vm_state_and_notify(context,
                     'compute_task', 'migrate_server',
                     dict(vm_state=instance['vm_state'],
                          task_state=None,
                          expected_task_state=task_states.MIGRATING,),
                     ex, request_spec, self.db)
     except Exception as ex:
         LOG.error(_('Migration of instance %(instance_id)s to host'
                    ' %(dest)s unexpectedly failed.'),
                    {'instance_id': instance['uuid'], 'dest': destination},
                    exc_info=True)
         raise exception.MigrationError(reason=ex)
Beispiel #2
0
 def _live_migrate(self, context, instance, scheduler_hint,
                   block_migration, disk_over_commit):
     destination = scheduler_hint.get("host")
     try:
         live_migrate.execute(context, instance, destination,
                          block_migration, disk_over_commit)
     except (exception.NoValidHost,
             exception.ComputeServiceUnavailable,
             exception.InvalidHypervisorType,
             exception.UnableToMigrateToSelf,
             exception.DestinationHypervisorTooOld,
             exception.InvalidLocalStorage,
             exception.InvalidSharedStorage,
             exception.MigrationPreCheckError) as ex:
         with excutils.save_and_reraise_exception():
             #TODO(johngarbutt) - eventually need instance actions here
             request_spec = {'instance_properties': {
                 'uuid': instance['uuid'], },
             }
             scheduler_utils.set_vm_state_and_notify(context,
                     'compute_task', 'migrate_server',
                     dict(vm_state=instance['vm_state'],
                          task_state=None,
                          expected_task_state=task_states.MIGRATING,),
                     ex, request_spec, self.db)
     except Exception as ex:
         with excutils.save_and_reraise_exception():
             request_spec = {'instance_properties': {
                 'uuid': instance['uuid'], },
             }
             scheduler_utils.set_vm_state_and_notify(context,
                     'compute_task', 'migrate_server',
                     {'vm_state': vm_states.ERROR},
                     ex, request_spec, self.db)
Beispiel #3
0
 def _live_migrate(self, context, instance, scheduler_hint, block_migration, disk_over_commit):
     destination = scheduler_hint.get("host")
     try:
         live_migrate.execute(context, instance, destination, block_migration, disk_over_commit)
     except (
         exception.NoValidHost,
         exception.ComputeServiceUnavailable,
         exception.InvalidHypervisorType,
         exception.InvalidCPUInfo,
         exception.UnableToMigrateToSelf,
         exception.DestinationHypervisorTooOld,
         exception.InvalidLocalStorage,
         exception.InvalidSharedStorage,
         exception.HypervisorUnavailable,
         exception.MigrationPreCheckError,
     ) as ex:
         with excutils.save_and_reraise_exception():
             # TODO(johngarbutt) - eventually need instance actions here
             request_spec = {"instance_properties": {"uuid": instance["uuid"]}}
             scheduler_utils.set_vm_state_and_notify(
                 context,
                 "compute_task",
                 "migrate_server",
                 dict(vm_state=instance["vm_state"], task_state=None, expected_task_state=task_states.MIGRATING),
                 ex,
                 request_spec,
                 self.db,
             )
     except Exception as ex:
         LOG.error(
             _("Migration of instance %(instance_id)s to host" " %(dest)s unexpectedly failed."),
             {"instance_id": instance["uuid"], "dest": destination},
             exc_info=True,
         )
         raise exception.MigrationError(reason=ex)
Beispiel #4
0
 def _live_migrate(self, context, instance, scheduler_hint, block_migration,
                   disk_over_commit):
     destination = scheduler_hint.get("host")
     try:
         live_migrate.execute(context, instance, destination,
                              block_migration, disk_over_commit)
     except (exception.NoValidHost, exception.ComputeServiceUnavailable,
             exception.InvalidHypervisorType,
             exception.UnableToMigrateToSelf,
             exception.DestinationHypervisorTooOld,
             exception.InvalidLocalStorage, exception.InvalidSharedStorage,
             exception.MigrationPreCheckError) as ex:
         with excutils.save_and_reraise_exception():
             #TODO(johngarbutt) - eventually need instance actions here
             request_spec = {
                 'instance_properties': {
                     'uuid': instance['uuid'],
                 },
             }
             scheduler_utils.set_vm_state_and_notify(
                 context, 'compute_task', 'migrate_server',
                 dict(
                     vm_state=instance['vm_state'],
                     task_state=None,
                     expected_task_state=task_states.MIGRATING,
                 ), ex, request_spec, self.db)
     except Exception as ex:
         with excutils.save_and_reraise_exception():
             request_spec = {
                 'instance_properties': {
                     'uuid': instance['uuid'],
                 },
             }
             scheduler_utils.set_vm_state_and_notify(
                 context, 'compute_task', 'migrate_server',
                 {'vm_state': vm_states.ERROR}, ex, request_spec, self.db)
Beispiel #5
0
    def _live_migrate(self, context, instance, scheduler_hint,
                      block_migration, disk_over_commit):
        destination = scheduler_hint.get("host")

        def _set_vm_state(context, instance, ex, vm_state=None,
                          task_state=None):
            request_spec = {'instance_properties': {
                'uuid': instance.uuid, },
            }
            scheduler_utils.set_vm_state_and_notify(context,
                instance.uuid,
                'compute_task', 'migrate_server',
                dict(vm_state=vm_state,
                     task_state=task_state,
                     expected_task_state=task_states.MIGRATING,),
                ex, request_spec, self.db)

        migration = objects.Migration(context=context.elevated())
        migration.dest_compute = destination
        migration.status = 'pre-migrating'
        migration.instance_uuid = instance.uuid
        migration.source_compute = instance.host
        migration.migration_type = 'live-migration'
        if instance.obj_attr_is_set('flavor'):
            migration.old_instance_type_id = instance.flavor.id
            migration.new_instance_type_id = instance.flavor.id
        else:
            migration.old_instance_type_id = instance.instance_type_id
            migration.new_instance_type_id = instance.instance_type_id
        migration.create()

        try:
            live_migrate.execute(context, instance, destination,
                                 block_migration, disk_over_commit,
                                 migration)
        except (exception.NoValidHost,
                exception.ComputeServiceUnavailable,
                exception.InvalidHypervisorType,
                exception.InvalidCPUInfo,
                exception.UnableToMigrateToSelf,
                exception.DestinationHypervisorTooOld,
                exception.InvalidLocalStorage,
                exception.InvalidSharedStorage,
                exception.HypervisorUnavailable,
                exception.InstanceInvalidState,
                exception.MigrationPreCheckError,
                exception.LiveMigrationWithOldNovaNotSafe) as ex:
            with excutils.save_and_reraise_exception():
                # TODO(johngarbutt) - eventually need instance actions here
                _set_vm_state(context, instance, ex, instance.vm_state)
                migration.status = 'error'
                migration.save()
        except Exception as ex:
            LOG.error(_LE('Migration of instance %(instance_id)s to host'
                          ' %(dest)s unexpectedly failed.'),
                      {'instance_id': instance.uuid, 'dest': destination},
                      exc_info=True)
            _set_vm_state(context, instance, ex, vm_states.ERROR,
                          instance.task_state)
            migration.status = 'failed'
            migration.save()
            raise exception.MigrationError(reason=six.text_type(ex))
Beispiel #6
0
    def _live_migrate(self, context, instance, scheduler_hint, block_migration,
                      disk_over_commit):
        destination = scheduler_hint.get("host")

        def _set_vm_state(context,
                          instance,
                          ex,
                          vm_state=None,
                          task_state=None):
            request_spec = {
                'instance_properties': {
                    'uuid': instance.uuid,
                },
            }
            scheduler_utils.set_vm_state_and_notify(
                context, instance.uuid, 'compute_task', 'migrate_server',
                dict(
                    vm_state=vm_state,
                    task_state=task_state,
                    expected_task_state=task_states.MIGRATING,
                ), ex, request_spec, self.db)

        migration = objects.Migration(context=context.elevated())
        migration.dest_compute = destination
        migration.status = 'pre-migrating'
        migration.instance_uuid = instance.uuid
        migration.source_compute = instance.host
        migration.migration_type = 'live-migration'
        if instance.obj_attr_is_set('flavor'):
            migration.old_instance_type_id = instance.flavor.id
            migration.new_instance_type_id = instance.flavor.id
        else:
            migration.old_instance_type_id = instance.instance_type_id
            migration.new_instance_type_id = instance.instance_type_id
        migration.create()

        try:
            live_migrate.execute(context, instance, destination,
                                 block_migration, disk_over_commit, migration)
        except (exception.NoValidHost, exception.ComputeServiceUnavailable,
                exception.InvalidHypervisorType, exception.InvalidCPUInfo,
                exception.UnableToMigrateToSelf,
                exception.DestinationHypervisorTooOld,
                exception.InvalidLocalStorage, exception.InvalidSharedStorage,
                exception.HypervisorUnavailable,
                exception.InstanceInvalidState,
                exception.MigrationPreCheckError,
                exception.LiveMigrationWithOldNovaNotSafe) as ex:
            with excutils.save_and_reraise_exception():
                # TODO(johngarbutt) - eventually need instance actions here
                _set_vm_state(context, instance, ex, instance.vm_state)
                migration.status = 'error'
                migration.save()
        except Exception as ex:
            LOG.error(_LE('Migration of instance %(instance_id)s to host'
                          ' %(dest)s unexpectedly failed.'), {
                              'instance_id': instance.uuid,
                              'dest': destination
                          },
                      exc_info=True)
            _set_vm_state(context, instance, ex, vm_states.ERROR,
                          instance.task_state)
            migration.status = 'failed'
            migration.save()
            raise exception.MigrationError(reason=six.text_type(ex))