From 265d77e16774f37775c6befbf34837d165ca844e Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 17 Nov 2011 16:08:10 -0500 Subject: snapshot/backup in compute manager to use uuids Related to blueprint internal-uuids. Changes shapshot in the computer manager to expect uuids instead of ids. Also updates some compute api fakes. Change-Id: I525754ea065c7df9dfe1d093e4c94c02bebf4c02 --- nova/tests/api/openstack/fakes.py | 13 ++++++------- nova/tests/test_compute.py | 22 ++++++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index c12ae5eab..9f5383944 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -168,11 +168,10 @@ class stub_out_compute_api_snapshot(object): self.extra_props_last_call = None stubs.Set(nova.compute.API, 'snapshot', self.snapshot) - def snapshot(self, context, instance_id, name, extra_properties=None): + def snapshot(self, context, instance, name, extra_properties=None): self.extra_props_last_call = extra_properties - props = dict(instance_id=instance_id, instance_ref=instance_id) - props.update(extra_properties or {}) - return dict(id='123', status='ACTIVE', name=name, properties=props) + return dict(id='123', status='ACTIVE', name=name, + properties=extra_properties) class stub_out_compute_api_backup(object): @@ -182,11 +181,11 @@ class stub_out_compute_api_backup(object): self.extra_props_last_call = None stubs.Set(nova.compute.API, 'backup', self.backup) - def backup(self, context, instance_id, name, backup_type, rotation, + def backup(self, context, instance, name, backup_type, rotation, extra_properties=None): self.extra_props_last_call = extra_properties - props = dict(instance_id=instance_id, instance_ref=instance_id, - backup_type=backup_type, rotation=rotation) + props = dict(backup_type=backup_type, + rotation=rotation) props.update(extra_properties or {}) return dict(id='123', status='ACTIVE', name=name, properties=props) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 397b5e268..93cf1a935 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -333,10 +333,12 @@ class ComputeTestCase(BaseTestCase): def test_snapshot(self): """Ensure instance can be snapshotted""" - instance_id = self._create_instance() + instance = self._create_fake_instance() + instance_id = instance['id'] + instance_uuid = instance['uuid'] name = "myfakesnapshot" self.compute.run_instance(self.context, instance_id) - self.compute.snapshot_instance(self.context, instance_id, name) + self.compute.snapshot_instance(self.context, instance_uuid, name) self.compute.terminate_instance(self.context, instance_id) def test_console_output(self): @@ -1316,21 +1318,20 @@ class ComputeAPITestCase(BaseTestCase): def test_snapshot(self): """Can't backup an instance which is already being backed up.""" - instance_id = self._create_instance() - instance = self.compute_api.get(self.context, instance_id) + instance = self._create_fake_instance() self.compute_api.snapshot(self.context, instance, None, None) - db.instance_destroy(self.context, instance_id) + db.instance_destroy(self.context, instance['id']) def test_backup(self): """Can't backup an instance which is already being backed up.""" - instance_id = self._create_instance() - instance = self.compute_api.get(self.context, instance_id) + instance = self._create_fake_instance() self.compute_api.backup(self.context, instance, None, None, None) - db.instance_destroy(self.context, instance_id) + db.instance_destroy(self.context, instance['id']) def test_backup_conflict(self): """Can't backup an instance which is already being backed up.""" - instance_id = self._create_instance() + instance = self._create_fake_instance() + instance_id = instance['id'] instance_values = {'task_state': task_states.IMAGE_BACKUP} db.instance_update(self.context, instance_id, instance_values) instance = self.compute_api.get(self.context, instance_id) @@ -1347,7 +1348,8 @@ class ComputeAPITestCase(BaseTestCase): def test_snapshot_conflict(self): """Can't snapshot an instance which is already being snapshotted.""" - instance_id = self._create_instance() + instance = self._create_fake_instance() + instance_id = instance['id'] instance_values = {'task_state': task_states.IMAGE_SNAPSHOT} db.instance_update(self.context, instance_id, instance_values) instance = self.compute_api.get(self.context, instance_id) -- cgit