From 36dc58791482d44d63d63e9780451f9499619f05 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 30 Jul 2012 15:20:56 -0400 Subject: Send a full instance in rollback_live_migration_at_destination. Change the rollback_live_migration_at_destination method of the compute rpc API to take a full instance over rpc instead of just the instance ID. This cuts down on database access needed by nova-compute. This was the last method of this API that was taking an instance ID as an argument. There still some left that take the instance UUID, but I can see the light at the end of the tunnel. Part of blueprint no-db-messaging. Change-Id: Id581d23d36fee5c6fc06d2a655e999fb9aae5ae3 --- nova/tests/compute/test_compute.py | 4 ++-- nova/tests/compute/test_rpcapi.py | 9 ++++----- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 36d001966..030314dc5 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -1625,8 +1625,8 @@ class ComputeTestCase(BaseTestCase): "version": "1.26"}, None) rpc.cast(c, topic, {"method": "rollback_live_migration_at_destination", - "args": {'instance_id': inst_id}, - "version": "1.0"}) + "args": {'instance': rpcinst}, + "version": "1.32"}) # start test self.mox.ReplayAll() diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 7a1195fe0..9b55bbb97 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -60,6 +60,7 @@ class ComputeRpcAPITestCase(test.TestCase): 'rebuild_instance', 'remove_fixed_ip_from_instance', 'remove_volume_connection', 'rescue_instance', 'reset_network', 'resize_instance', 'resume_instance', 'revert_resize', + 'rollback_live_migration_at_destination', 'start_instance', 'stop_instance', 'suspend_instance', 'unpause_instance' ] @@ -86,10 +87,7 @@ class ComputeRpcAPITestCase(test.TestCase): methods_with_instance): instance = expected_msg['args']['instance'] del expected_msg['args']['instance'] - if method in ['rollback_live_migration_at_destination']: - expected_msg['args']['instance_id'] = instance['id'] - else: - expected_msg['args']['instance_uuid'] = instance['uuid'] + expected_msg['args']['instance_uuid'] = instance['uuid'] expected_msg['version'] = expected_version cast_and_call = ['confirm_resize', 'stop_instance'] @@ -291,7 +289,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_rollback_live_migration_at_destination(self): self._test_compute_api('rollback_live_migration_at_destination', - 'cast', instance=self.fake_instance, host='host') + 'cast', instance=self.fake_instance, host='host', + version='1.32') def test_set_admin_password(self): self._test_compute_api('set_admin_password', 'cast', -- cgit From 99f6c32bf8a5204da0e07137486c61cdba5318a3 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 30 Jul 2012 15:39:18 -0400 Subject: Send a full instance in set_admin_password. Change the set_admin_password method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: Iddcc7cb068090faa98f0bb87307e09d5b0ebf0c2 --- nova/tests/compute/test_compute.py | 12 +++++++----- nova/tests/compute/test_rpcapi.py | 4 ++-- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 030314dc5..4dbcd3522 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -589,7 +589,7 @@ class ComputeTestCase(BaseTestCase): def test_set_admin_password(self): """Ensure instance can have its admin password set""" - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) self.compute.run_instance(self.context, instance['uuid']) db.instance_update(self.context, instance['uuid'], {'task_state': task_states.UPDATING_PASSWORD}) @@ -598,7 +598,7 @@ class ComputeTestCase(BaseTestCase): self.assertEqual(inst_ref['vm_state'], vm_states.ACTIVE) self.assertEqual(inst_ref['task_state'], task_states.UPDATING_PASSWORD) - self.compute.set_admin_password(self.context, instance['uuid']) + self.compute.set_admin_password(self.context, instance=instance) inst_ref = db.instance_get_by_uuid(self.context, instance['uuid']) self.assertEqual(inst_ref['vm_state'], vm_states.ACTIVE) @@ -613,7 +613,8 @@ class ComputeTestCase(BaseTestCase): db.instance_update(self.context, instance['uuid'], { "power_state": power_state.NOSTATE, }) - instance = db.instance_get_by_uuid(self.context, instance['uuid']) + instance = jsonutils.to_primitive(db.instance_get_by_uuid( + self.context, instance['uuid'])) self.assertEqual(instance['power_state'], power_state.NOSTATE) @@ -630,7 +631,7 @@ class ComputeTestCase(BaseTestCase): self.assertRaises(exception.Invalid, self.compute.set_admin_password, self.context, - instance['uuid']) + instance=instance) self.compute.terminate_instance(self.context, instance['uuid']) def test_set_admin_password_driver_error(self): @@ -660,7 +661,8 @@ class ComputeTestCase(BaseTestCase): #so a new error is raised self.assertRaises(exception.NovaException, self.compute.set_admin_password, - self.context, instance['uuid']) + self.context, + instance=jsonutils.to_primitive(inst_ref)) inst_ref = db.instance_get_by_uuid(self.context, instance['uuid']) self.assertEqual(inst_ref['vm_state'], vm_states.ERROR) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index 9b55bbb97..e726606d4 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -60,7 +60,7 @@ class ComputeRpcAPITestCase(test.TestCase): 'rebuild_instance', 'remove_fixed_ip_from_instance', 'remove_volume_connection', 'rescue_instance', 'reset_network', 'resize_instance', 'resume_instance', 'revert_resize', - 'rollback_live_migration_at_destination', + 'rollback_live_migration_at_destination', 'set_admin_password', 'start_instance', 'stop_instance', 'suspend_instance', 'unpause_instance' ] @@ -294,7 +294,7 @@ class ComputeRpcAPITestCase(test.TestCase): def test_set_admin_password(self): self._test_compute_api('set_admin_password', 'cast', - instance=self.fake_instance, new_pass='pw') + instance=self.fake_instance, new_pass='pw', version='1.33') def test_set_host_enabled(self): self._test_compute_api('set_host_enabled', 'call', -- cgit From 773d1d61a72700ad5170c259d599891f1dd0a609 Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Mon, 30 Jul 2012 16:08:50 -0400 Subject: Send a full instance in snapshot_instance. Change the snapshot_instance method of the compute rpc API to take a full instance over rpc instead of just the instance UUID. This cuts down on database access needed by nova-compute. Part of blueprint no-db-messaging. Change-Id: I401beb932e329683c3434ecd643db345aa217492 --- nova/tests/compute/test_compute.py | 8 ++++---- nova/tests/compute/test_rpcapi.py | 7 ++++--- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 4dbcd3522..874804152 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -749,11 +749,11 @@ class ComputeTestCase(BaseTestCase): def test_snapshot(self): """Ensure instance can be snapshotted""" - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) instance_uuid = instance['uuid'] name = "myfakesnapshot" self.compute.run_instance(self.context, instance_uuid) - self.compute.snapshot_instance(self.context, instance_uuid, name) + self.compute.snapshot_instance(self.context, name, instance=instance) self.compute.terminate_instance(self.context, instance_uuid) def test_snapshot_fails(self): @@ -763,11 +763,11 @@ class ComputeTestCase(BaseTestCase): self.stubs.Set(self.compute.driver, 'snapshot', fake_snapshot) - instance = self._create_fake_instance() + instance = jsonutils.to_primitive(self._create_fake_instance()) self.compute.run_instance(self.context, instance['uuid']) self.assertRaises(test.TestingException, self.compute.snapshot_instance, - self.context, instance['uuid'], "failing_snapshot") + self.context, "failing_snapshot", instance=instance) self._assert_state({'task_state': None}) self.compute.terminate_instance(self.context, instance['uuid']) diff --git a/nova/tests/compute/test_rpcapi.py b/nova/tests/compute/test_rpcapi.py index e726606d4..cafd7fd55 100644 --- a/nova/tests/compute/test_rpcapi.py +++ b/nova/tests/compute/test_rpcapi.py @@ -61,8 +61,8 @@ class ComputeRpcAPITestCase(test.TestCase): 'remove_volume_connection', 'rescue_instance', 'reset_network', 'resize_instance', 'resume_instance', 'revert_resize', 'rollback_live_migration_at_destination', 'set_admin_password', - 'start_instance', 'stop_instance', 'suspend_instance', - 'unpause_instance' + 'snapshot_instance', 'start_instance', 'stop_instance', + 'suspend_instance', 'unpause_instance' ] if 'rpcapi_class' in kwargs: @@ -307,7 +307,8 @@ class ComputeRpcAPITestCase(test.TestCase): def test_snapshot_instance(self): self._test_compute_api('snapshot_instance', 'cast', instance=self.fake_instance, image_id='id', image_type='type', - backup_type='type', rotation='rotation') + backup_type='type', rotation='rotation', + version='1.34') def test_start_instance(self): self._test_compute_api('start_instance', 'cast', -- cgit