@@ -618,7 +618,7 @@ def update_compute_provider_status(self, context, rp_uuid, enabled):
618
618
class ComputeManager(manager.Manager):
619
619
"""Manages the running instances from creation to destruction."""
620
620
621
- target = messaging.Target(version='6.1 ')
621
+ target = messaging.Target(version='6.2 ')
622
622
623
623
def __init__(self, compute_driver=None, *args, **kwargs):
624
624
"""Load configuration options and connect to the hypervisor."""
@@ -3696,7 +3696,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3696
3696
bdms, recreate, on_shared_storage,
3697
3697
preserve_ephemeral, migration,
3698
3698
scheduled_node, limits, request_spec, accel_uuids,
3699
- reimage_boot_volume):
3699
+ reimage_boot_volume, target_state ):
3700
3700
"""Destroy and re-make this instance.
3701
3701
3702
3702
A 'rebuild' effectively purges all existing data from the system and
@@ -3731,6 +3731,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3731
3731
:param reimage_boot_volume: Boolean to specify whether the user has
3732
3732
explicitly requested to rebuild a boot
3733
3733
volume
3734
+ :param target_state: Set a target state for the evacuated instance.
3734
3735
3735
3736
"""
3736
3737
# recreate=True means the instance is being evacuated from a failed
@@ -3795,7 +3796,8 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3795
3796
image_meta, injected_files, new_pass, orig_sys_metadata,
3796
3797
bdms, evacuate, on_shared_storage, preserve_ephemeral,
3797
3798
migration, request_spec, allocs, rebuild_claim,
3798
- scheduled_node, limits, accel_uuids, reimage_boot_volume)
3799
+ scheduled_node, limits, accel_uuids, reimage_boot_volume,
3800
+ target_state)
3799
3801
except (exception.ComputeResourcesUnavailable,
3800
3802
exception.RescheduledException) as e:
3801
3803
if isinstance(e, exception.ComputeResourcesUnavailable):
@@ -3855,7 +3857,7 @@ def _do_rebuild_instance_with_claim(
3855
3857
injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3856
3858
on_shared_storage, preserve_ephemeral, migration, request_spec,
3857
3859
allocations, rebuild_claim, scheduled_node, limits, accel_uuids,
3858
- reimage_boot_volume):
3860
+ reimage_boot_volume, target_state ):
3859
3861
"""Helper to avoid deep nesting in the top-level method."""
3860
3862
3861
3863
provider_mapping = None
@@ -3879,7 +3881,8 @@ def _do_rebuild_instance_with_claim(
3879
3881
context, instance, orig_image_ref, image_meta, injected_files,
3880
3882
new_pass, orig_sys_metadata, bdms, evacuate, on_shared_storage,
3881
3883
preserve_ephemeral, migration, request_spec, allocations,
3882
- provider_mapping, accel_uuids, reimage_boot_volume)
3884
+ provider_mapping, accel_uuids, reimage_boot_volume,
3885
+ target_state)
3883
3886
3884
3887
@staticmethod
3885
3888
def _get_image_name(image_meta):
@@ -3893,10 +3896,18 @@ def _do_rebuild_instance(
3893
3896
injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3894
3897
on_shared_storage, preserve_ephemeral, migration, request_spec,
3895
3898
allocations, request_group_resource_providers_mapping,
3896
- accel_uuids, reimage_boot_volume):
3899
+ accel_uuids, reimage_boot_volume, target_state ):
3897
3900
orig_vm_state = instance.vm_state
3898
3901
3899
3902
if evacuate:
3903
+ if target_state and orig_vm_state != vm_states.ERROR:
3904
+ # This will ensure that at destination the instance will have
3905
+ # the desired state.
3906
+ if target_state not in vm_states.ALLOW_TARGET_STATES:
3907
+ raise exception.InstanceEvacuateNotSupportedTargetState(
3908
+ target_state=target_state)
3909
+ orig_vm_state = target_state
3910
+
3900
3911
if request_spec:
3901
3912
# NOTE(gibi): Do a late check of server group policy as
3902
3913
# parallel scheduling could violate such policy. This will
@@ -11369,7 +11380,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
11369
11380
bdms, recreate, on_shared_storage,
11370
11381
preserve_ephemeral, migration,
11371
11382
scheduled_node, limits, request_spec,
11372
- accel_uuids, False)
11383
+ accel_uuids, False, None )
11373
11384
11374
11385
# 5.13 support for optional accel_uuids argument
11375
11386
def shelve_instance(self, context, instance, image_id,
0 commit comments