'Starts the migration of a running instance to another host.'

@wrap_exception()
@reverts_task_state
@wrap_instance_event(prefix='compute')
@errors_out_migration
@wrap_instance_fault
def resize_instance(self, context, instance, image, reservations, migration, instance_type, clean_shutdown):

    with self._error_out_instance_on_exception(context, instance):
        if ((not instance_type) or (not isinstance(instance_type, objects.Flavor))):
            instance_type = objects.Flavor.get_by_id(context, migration['new_instance_type_id'])
        network_info = self.network_api.get_instance_nw_info(context, instance)
        migration.status = 'migrating'
        with migration.obj_as_admin():
            migration.save()
        instance.task_state = task_states.RESIZE_MIGRATING
        instance.save(expected_task_state=task_states.RESIZE_PREP)
        self._notify_about_instance_usage(context, instance, 'resize.start', network_info=network_info)
        compute_utils.notify_about_instance_action(context, instance, self.host, action=fields.NotificationAction.RESIZE, phase=fields.NotificationPhase.START)
        bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(context, instance.uuid)
        block_device_info = self._get_instance_block_device_info(context, instance, bdms=bdms)
        (timeout, retry_interval) = self._get_power_off_values(context, instance, clean_shutdown)
        disk_info = self.driver.migrate_disk_and_power_off(context, instance, migration.dest_host, instance_type, network_info, block_device_info, timeout, retry_interval)
        self._terminate_volume_connections(context, instance, bdms)
        migration_p = obj_base.obj_to_primitive(migration)
        self.network_api.migrate_instance_start(context, instance, migration_p)
        migration.status = 'post-migrating'
        with migration.obj_as_admin():
            migration.save()
        instance.host = migration.dest_compute
        instance.node = migration.dest_node
        instance.task_state = task_states.RESIZE_MIGRATED
        instance.save(expected_task_state=task_states.RESIZE_MIGRATING)
        self.compute_rpcapi.finish_resize(context, instance, migration, image, disk_info, migration.dest_compute)
        self._notify_about_instance_usage(context, instance, 'resize.end', network_info=network_info)
        compute_utils.notify_about_instance_action(context, instance, self.host, action=fields.NotificationAction.RESIZE, phase=fields.NotificationPhase.END)
        self.instance_events.clear_events_for_instance(instance)
