@@ -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."""
@@ -3674,7 +3674,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3674
3674
bdms, recreate, on_shared_storage,
3675
3675
preserve_ephemeral, migration,
3676
3676
scheduled_node, limits, request_spec, accel_uuids,
3677
- reimage_boot_volume):
3677
+ reimage_boot_volume, target_state ):
3678
3678
"""Destroy and re-make this instance.
3679
3679
3680
3680
A 'rebuild' effectively purges all existing data from the system and
@@ -3709,6 +3709,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3709
3709
:param reimage_boot_volume: Boolean to specify whether the user has
3710
3710
explicitly requested to rebuild a boot
3711
3711
volume
3712
+ :param target_state: Set a target state for the evacuated instance.
3712
3713
3713
3714
"""
3714
3715
# recreate=True means the instance is being evacuated from a failed
@@ -3773,7 +3774,8 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
3773
3774
image_meta, injected_files, new_pass, orig_sys_metadata,
3774
3775
bdms, evacuate, on_shared_storage, preserve_ephemeral,
3775
3776
migration, request_spec, allocs, rebuild_claim,
3776
- scheduled_node, limits, accel_uuids, reimage_boot_volume)
3777
+ scheduled_node, limits, accel_uuids, reimage_boot_volume,
3778
+ target_state)
3777
3779
except (exception.ComputeResourcesUnavailable,
3778
3780
exception.RescheduledException) as e:
3779
3781
if isinstance(e, exception.ComputeResourcesUnavailable):
@@ -3833,7 +3835,7 @@ def _do_rebuild_instance_with_claim(
3833
3835
injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3834
3836
on_shared_storage, preserve_ephemeral, migration, request_spec,
3835
3837
allocations, rebuild_claim, scheduled_node, limits, accel_uuids,
3836
- reimage_boot_volume):
3838
+ reimage_boot_volume, target_state ):
3837
3839
"""Helper to avoid deep nesting in the top-level method."""
3838
3840
3839
3841
provider_mapping = None
@@ -3857,7 +3859,8 @@ def _do_rebuild_instance_with_claim(
3857
3859
context, instance, orig_image_ref, image_meta, injected_files,
3858
3860
new_pass, orig_sys_metadata, bdms, evacuate, on_shared_storage,
3859
3861
preserve_ephemeral, migration, request_spec, allocations,
3860
- provider_mapping, accel_uuids, reimage_boot_volume)
3862
+ provider_mapping, accel_uuids, reimage_boot_volume,
3863
+ target_state)
3861
3864
3862
3865
@staticmethod
3863
3866
def _get_image_name(image_meta):
@@ -3871,10 +3874,18 @@ def _do_rebuild_instance(
3871
3874
injected_files, new_pass, orig_sys_metadata, bdms, evacuate,
3872
3875
on_shared_storage, preserve_ephemeral, migration, request_spec,
3873
3876
allocations, request_group_resource_providers_mapping,
3874
- accel_uuids, reimage_boot_volume):
3877
+ accel_uuids, reimage_boot_volume, target_state ):
3875
3878
orig_vm_state = instance.vm_state
3876
3879
3877
3880
if evacuate:
3881
+ if target_state and orig_vm_state != vm_states.ERROR:
3882
+ # This will ensure that at destination the instance will have
3883
+ # the desired state.
3884
+ if target_state not in vm_states.ALLOW_TARGET_STATES:
3885
+ raise exception.InstanceEvacuateNotSupportedTargetState(
3886
+ target_state=target_state)
3887
+ orig_vm_state = target_state
3888
+
3878
3889
if request_spec:
3879
3890
# NOTE(gibi): Do a late check of server group policy as
3880
3891
# parallel scheduling could violate such policy. This will
@@ -11347,7 +11358,7 @@ def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
11347
11358
bdms, recreate, on_shared_storage,
11348
11359
preserve_ephemeral, migration,
11349
11360
scheduled_node, limits, request_spec,
11350
- accel_uuids, False)
11361
+ accel_uuids, False, None )
11351
11362
11352
11363
# 5.13 support for optional accel_uuids argument
11353
11364
def shelve_instance(self, context, instance, image_id,
0 commit comments