Merge "Send block device mappings to rebuild_instance."
This commit is contained in:
commit
301016a875
@ -1551,10 +1551,13 @@ class API(base.Base):
|
|||||||
# system metadata... and copy in the properties for the new image.
|
# system metadata... and copy in the properties for the new image.
|
||||||
orig_sys_metadata = _reset_image_metadata()
|
orig_sys_metadata = _reset_image_metadata()
|
||||||
|
|
||||||
|
bdms = self.db.block_device_mapping_get_all_by_instance(context,
|
||||||
|
instance['uuid'])
|
||||||
|
|
||||||
self.compute_rpcapi.rebuild_instance(context, instance=instance,
|
self.compute_rpcapi.rebuild_instance(context, instance=instance,
|
||||||
new_pass=admin_password, injected_files=files_to_inject,
|
new_pass=admin_password, injected_files=files_to_inject,
|
||||||
image_ref=image_href, orig_image_ref=orig_image_ref,
|
image_ref=image_href, orig_image_ref=orig_image_ref,
|
||||||
orig_sys_metadata=orig_sys_metadata)
|
orig_sys_metadata=orig_sys_metadata, bdms=bdms)
|
||||||
|
|
||||||
@wrap_check_policy
|
@wrap_check_policy
|
||||||
@check_instance_lock
|
@check_instance_lock
|
||||||
|
@ -280,7 +280,7 @@ class ComputeVirtAPI(virtapi.VirtAPI):
|
|||||||
class ComputeManager(manager.SchedulerDependentManager):
|
class ComputeManager(manager.SchedulerDependentManager):
|
||||||
"""Manages the running instances from creation to destruction."""
|
"""Manages the running instances from creation to destruction."""
|
||||||
|
|
||||||
RPC_API_VERSION = '2.17'
|
RPC_API_VERSION = '2.18'
|
||||||
|
|
||||||
def __init__(self, compute_driver=None, *args, **kwargs):
|
def __init__(self, compute_driver=None, *args, **kwargs):
|
||||||
"""Load configuration options and connect to the hypervisor."""
|
"""Load configuration options and connect to the hypervisor."""
|
||||||
@ -1173,7 +1173,8 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
@reverts_task_state
|
@reverts_task_state
|
||||||
@wrap_instance_fault
|
@wrap_instance_fault
|
||||||
def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
|
def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
|
||||||
injected_files, new_pass, orig_sys_metadata=None):
|
injected_files, new_pass, orig_sys_metadata=None,
|
||||||
|
bdms=None):
|
||||||
"""Destroy and re-make this instance.
|
"""Destroy and re-make this instance.
|
||||||
|
|
||||||
A 'rebuild' effectively purges all existing data from the system and
|
A 'rebuild' effectively purges all existing data from the system and
|
||||||
@ -1227,6 +1228,7 @@ class ComputeManager(manager.SchedulerDependentManager):
|
|||||||
instance.injected_files = injected_files
|
instance.injected_files = injected_files
|
||||||
network_info = self.network_api.get_instance_nw_info(context,
|
network_info = self.network_api.get_instance_nw_info(context,
|
||||||
instance)
|
instance)
|
||||||
|
if bdms is None:
|
||||||
bdms = self.db.block_device_mapping_get_all_by_instance(
|
bdms = self.db.block_device_mapping_get_all_by_instance(
|
||||||
context, instance['uuid'])
|
context, instance['uuid'])
|
||||||
device_info = self._setup_block_device_mapping(context, instance,
|
device_info = self._setup_block_device_mapping(context, instance,
|
||||||
|
@ -145,6 +145,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
2.15 - Remove aggregate_id, add aggregate to remove_aggregate_host
|
2.15 - Remove aggregate_id, add aggregate to remove_aggregate_host
|
||||||
2.16 - Add instance_type to resize_instance
|
2.16 - Add instance_type to resize_instance
|
||||||
2.17 - Add get_backdoor_port()
|
2.17 - Add get_backdoor_port()
|
||||||
|
2.18 - Add bdms to rebuild_instance
|
||||||
'''
|
'''
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -378,15 +379,16 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
|||||||
version='2.5')
|
version='2.5')
|
||||||
|
|
||||||
def rebuild_instance(self, ctxt, instance, new_pass, injected_files,
|
def rebuild_instance(self, ctxt, instance, new_pass, injected_files,
|
||||||
image_ref, orig_image_ref, orig_sys_metadata):
|
image_ref, orig_image_ref, orig_sys_metadata, bdms):
|
||||||
instance_p = jsonutils.to_primitive(instance)
|
instance_p = jsonutils.to_primitive(instance)
|
||||||
|
bdms_p = jsonutils.to_primitive(bdms)
|
||||||
self.cast(ctxt, self.make_msg('rebuild_instance',
|
self.cast(ctxt, self.make_msg('rebuild_instance',
|
||||||
instance=instance_p, new_pass=new_pass,
|
instance=instance_p, new_pass=new_pass,
|
||||||
injected_files=injected_files, image_ref=image_ref,
|
injected_files=injected_files, image_ref=image_ref,
|
||||||
orig_image_ref=orig_image_ref,
|
orig_image_ref=orig_image_ref,
|
||||||
orig_sys_metadata=orig_sys_metadata),
|
orig_sys_metadata=orig_sys_metadata, bdms=bdms_p),
|
||||||
topic=_compute_topic(self.topic, ctxt, None, instance),
|
topic=_compute_topic(self.topic, ctxt, None, instance),
|
||||||
version='2.1')
|
version='2.18')
|
||||||
|
|
||||||
def refresh_provider_fw_rules(self, ctxt, host):
|
def refresh_provider_fw_rules(self, ctxt, host):
|
||||||
self.cast(ctxt, self.make_msg('refresh_provider_fw_rules'),
|
self.cast(ctxt, self.make_msg('refresh_provider_fw_rules'),
|
||||||
|
@ -890,7 +890,8 @@ class ComputeTestCase(BaseTestCase):
|
|||||||
image_ref, image_ref,
|
image_ref, image_ref,
|
||||||
injected_files=[],
|
injected_files=[],
|
||||||
new_pass="new_password",
|
new_pass="new_password",
|
||||||
orig_sys_metadata=sys_metadata)
|
orig_sys_metadata=sys_metadata,
|
||||||
|
bdms=[])
|
||||||
self.compute.terminate_instance(self.context, instance=instance)
|
self.compute.terminate_instance(self.context, instance=instance)
|
||||||
|
|
||||||
def test_rebuild_launch_time(self):
|
def test_rebuild_launch_time(self):
|
||||||
@ -909,8 +910,9 @@ class ComputeTestCase(BaseTestCase):
|
|||||||
self.compute.rebuild_instance(self.context, instance,
|
self.compute.rebuild_instance(self.context, instance,
|
||||||
image_ref, image_ref,
|
image_ref, image_ref,
|
||||||
injected_files=[],
|
injected_files=[],
|
||||||
new_pass="new_password")
|
new_pass="new_password",
|
||||||
instance = db.instance_get_by_uuid(self.context, instance_uuid)
|
bdms=[])
|
||||||
|
instance = db.instance_get_by_uuid(self.context, instance_uuid,)
|
||||||
self.assertEquals(cur_time, instance['launched_at'])
|
self.assertEquals(cur_time, instance['launched_at'])
|
||||||
self.compute.terminate_instance(self.context,
|
self.compute.terminate_instance(self.context,
|
||||||
instance=jsonutils.to_primitive(instance))
|
instance=jsonutils.to_primitive(instance))
|
||||||
@ -1720,7 +1722,8 @@ class ComputeTestCase(BaseTestCase):
|
|||||||
image_ref, new_image_ref,
|
image_ref, new_image_ref,
|
||||||
injected_files=[],
|
injected_files=[],
|
||||||
new_pass=password,
|
new_pass=password,
|
||||||
orig_sys_metadata=orig_sys_metadata)
|
orig_sys_metadata=orig_sys_metadata,
|
||||||
|
bdms=[])
|
||||||
|
|
||||||
instance = db.instance_get_by_uuid(self.context, inst_ref['uuid'])
|
instance = db.instance_get_by_uuid(self.context, inst_ref['uuid'])
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ class ComputeRpcAPITestCase(test.TestCase):
|
|||||||
self._test_compute_api('rebuild_instance', 'cast',
|
self._test_compute_api('rebuild_instance', 'cast',
|
||||||
instance=self.fake_instance, new_pass='pass',
|
instance=self.fake_instance, new_pass='pass',
|
||||||
injected_files='files', image_ref='ref',
|
injected_files='files', image_ref='ref',
|
||||||
orig_image_ref='orig_ref',
|
orig_image_ref='orig_ref', bdms=[],
|
||||||
orig_sys_metadata='orig_sys_metadata', version='2.1')
|
orig_sys_metadata='orig_sys_metadata', version='2.18')
|
||||||
|
|
||||||
def test_reserve_block_device_name(self):
|
def test_reserve_block_device_name(self):
|
||||||
self._test_compute_api('reserve_block_device_name', 'call',
|
self._test_compute_api('reserve_block_device_name', 'call',
|
||||||
|
Loading…
Reference in New Issue
Block a user