Fix rebuild with cells
When rebuild_instances switched to a compute task it broke cells since the cast was dropped as it didn't match. This change moves the rebuild_instances to conductor and also adds some unit tests checks on the compute task integration point. Change-Id: Ic1c575fbca72f1cd34b1dbc6f82023e5b2b392e2 Closes-Bug: 1348642
This commit is contained in:
parent
d003a85520
commit
f17ad7b933
|
@ -49,8 +49,7 @@ class ComputeRPCAPIRedirect(object):
|
|||
'unpause_instance', 'revert_resize',
|
||||
'confirm_resize', 'reset_network',
|
||||
'inject_network_info',
|
||||
'backup_instance', 'snapshot_instance',
|
||||
'rebuild_instance']
|
||||
'backup_instance', 'snapshot_instance']
|
||||
|
||||
def __init__(self, cells_rpcapi):
|
||||
self.cells_rpcapi = cells_rpcapi
|
||||
|
@ -70,7 +69,7 @@ class ConductorTaskRPCAPIRedirect(object):
|
|||
# is for transitioning to a common interface where we can just
|
||||
# swap out the compute_task_rpcapi class with the cells_rpcapi class.
|
||||
cells_compatible = ['build_instances', 'resize_instance',
|
||||
'live_migrate_instance']
|
||||
'live_migrate_instance', 'rebuild_instance']
|
||||
|
||||
def __init__(self, cells_rpcapi_obj):
|
||||
self.cells_rpcapi = cells_rpcapi_obj
|
||||
|
|
|
@ -274,6 +274,38 @@ class CellsConductorAPIRPCRedirect(test.NoDBTestCase):
|
|||
|
||||
self.assertTrue(self.cells_rpcapi.live_migrate_instance.called)
|
||||
|
||||
@mock.patch.object(objects.Instance, 'save')
|
||||
@mock.patch.object(objects.Instance, 'get_flavor')
|
||||
@mock.patch.object(objects.BlockDeviceMappingList, 'get_by_instance_uuid')
|
||||
@mock.patch.object(compute_api.API, '_get_image')
|
||||
@mock.patch.object(compute_api.API, '_check_auto_disk_config')
|
||||
@mock.patch.object(compute_api.API, '_checks_for_create_and_rebuild')
|
||||
@mock.patch.object(compute_api.API, '_record_action_start')
|
||||
def test_rebuild_instance(self, _record_action_start,
|
||||
_checks_for_create_and_rebuild, _check_auto_disk_config,
|
||||
_get_image, bdm_get_by_instance_uuid, get_flavor, instance_save):
|
||||
orig_system_metadata = {}
|
||||
instance = fake_instance.fake_instance_obj(self.context,
|
||||
vm_state=vm_states.ACTIVE, cell_name='fake-cell',
|
||||
launched_at=timeutils.utcnow(),
|
||||
system_metadata=orig_system_metadata,
|
||||
expected_attrs=['system_metadata'])
|
||||
get_flavor.return_value = ''
|
||||
image_href = ''
|
||||
image = {"min_ram": 10, "min_disk": 1,
|
||||
"properties": {'architecture': 'x86_64'}}
|
||||
admin_pass = ''
|
||||
files_to_inject = []
|
||||
bdms = []
|
||||
|
||||
_get_image.return_value = (None, image)
|
||||
bdm_get_by_instance_uuid.return_value = bdms
|
||||
|
||||
self.compute_api.rebuild(self.context, instance, image_href,
|
||||
admin_pass, files_to_inject)
|
||||
|
||||
self.assertTrue(self.cells_rpcapi.rebuild_instance.called)
|
||||
|
||||
def test_check_equal(self):
|
||||
task_api = self.compute_api.compute_task_api
|
||||
tests = set()
|
||||
|
|
Loading…
Reference in New Issue