Clean up compute API image_create
The _image_create() code in compute manager is the only place where db.instance_test_and_set is used.. which was added before 'expected_task_state' support was added to instance_update. By switching to use self.update(), we can also take advantage of it doing the state change notification for us. The instance update and the compute RPC call have been moved out of _create_image() and into snapshot() and backup() to support a future cells patch. Change-Id: Ib6603f732d28e49cb6f351447da5f6e41615dea5
This commit is contained in:
@@ -299,27 +299,6 @@ class DbApiTestCase(test.TestCase):
|
||||
self.assertRaises(exception.DuplicateVlan,
|
||||
db.network_create_safe, ctxt, values2)
|
||||
|
||||
def test_instance_test_and_set(self):
|
||||
ctxt = context.get_admin_context()
|
||||
states = [
|
||||
(None, [None, 'some'], 'building'),
|
||||
(None, [None], 'building'),
|
||||
('building', ['building'], 'ready'),
|
||||
('building', [None, 'building'], 'ready')]
|
||||
for st in states:
|
||||
inst = db.instance_create(ctxt, {'vm_state': st[0]})
|
||||
uuid = inst['uuid']
|
||||
db.instance_test_and_set(ctxt, uuid, 'vm_state', st[1], st[2])
|
||||
inst = db.instance_get_by_uuid(ctxt, uuid)
|
||||
self.assertEqual(inst["vm_state"], st[2])
|
||||
|
||||
def test_instance_test_and_set_exception(self):
|
||||
ctxt = context.get_admin_context()
|
||||
inst = db.instance_create(ctxt, {'vm_state': 'building'})
|
||||
self.assertRaises(exception.InstanceInvalidState,
|
||||
db.instance_test_and_set, ctxt,
|
||||
inst['uuid'], 'vm_state', [None, 'disable'], 'run')
|
||||
|
||||
def test_instance_update_with_instance_uuid(self):
|
||||
# test instance_update() works when an instance UUID is passed.
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
Reference in New Issue
Block a user