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
This commit is contained in:
Alex Meade
2011-11-17 16:08:10 -05:00
parent f43b65d848
commit 081d73e370
2 changed files with 14 additions and 12 deletions

View File

@@ -197,11 +197,11 @@ class InstanceBusy(NovaException):
class InstanceSnapshotting(InstanceBusy): class InstanceSnapshotting(InstanceBusy):
message = _("Instance %(instance_id)s is currently snapshotting.") message = _("Instance %(instance_uuid)s is currently snapshotting.")
class InstanceBackingUp(InstanceBusy): class InstanceBackingUp(InstanceBusy):
message = _("Instance %(instance_id)s is currently being backed up.") message = _("Instance %(instance_uuid)s is currently being backed up.")
class Invalid(NovaException): class Invalid(NovaException):

View File

@@ -333,10 +333,12 @@ class ComputeTestCase(BaseTestCase):
def test_snapshot(self): def test_snapshot(self):
"""Ensure instance can be snapshotted""" """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" name = "myfakesnapshot"
self.compute.run_instance(self.context, instance_id) 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) self.compute.terminate_instance(self.context, instance_id)
def test_console_output(self): def test_console_output(self):
@@ -1316,21 +1318,20 @@ class ComputeAPITestCase(BaseTestCase):
def test_snapshot(self): def test_snapshot(self):
"""Can't backup an instance which is already being backed up.""" """Can't backup an instance which is already being backed up."""
instance_id = self._create_instance() instance = self._create_fake_instance()
instance = self.compute_api.get(self.context, instance_id)
self.compute_api.snapshot(self.context, instance, None, None) 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): def test_backup(self):
"""Can't backup an instance which is already being backed up.""" """Can't backup an instance which is already being backed up."""
instance_id = self._create_instance() instance = self._create_fake_instance()
instance = self.compute_api.get(self.context, instance_id)
self.compute_api.backup(self.context, instance, None, None, None) 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): def test_backup_conflict(self):
"""Can't backup an instance which is already being backed up.""" """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} instance_values = {'task_state': task_states.IMAGE_BACKUP}
db.instance_update(self.context, instance_id, instance_values) db.instance_update(self.context, instance_id, instance_values)
instance = self.compute_api.get(self.context, instance_id) instance = self.compute_api.get(self.context, instance_id)
@@ -1347,7 +1348,8 @@ class ComputeAPITestCase(BaseTestCase):
def test_snapshot_conflict(self): def test_snapshot_conflict(self):
"""Can't snapshot an instance which is already being snapshotted.""" """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} instance_values = {'task_state': task_states.IMAGE_SNAPSHOT}
db.instance_update(self.context, instance_id, instance_values) db.instance_update(self.context, instance_id, instance_values)
instance = self.compute_api.get(self.context, instance_id) instance = self.compute_api.get(self.context, instance_id)