Converting reboot to use instance objects

Related to blueprint internal-uuids

Change-Id: I50ebfdfd9c7193e732a3e2c2e1b1b3b32eb1bb57
This commit is contained in:
Brian Waldon
2011-11-08 14:32:44 -05:00
parent 8029a95d92
commit 2ee08cbb14
2 changed files with 12 additions and 6 deletions

View File

@@ -332,6 +332,12 @@ class reroute_compute(object):
context and resource id. Derived class should override this.""" context and resource id. Derived class should override this."""
context = kwargs.get('context', None) context = kwargs.get('context', None)
instance_id = kwargs.get('instance_id', None) instance_id = kwargs.get('instance_id', None)
#NOTE(blamar): This is going to get worse before it gets better...
instance = kwargs.get('instance', None)
if instance is not None:
instance_id = instance['uuid']
if len(args) > 0 and not context: if len(args) > 0 and not context:
context = args[1] context = args[1]
if len(args) > 1 and not instance_id: if len(args) > 1 and not instance_id:

View File

@@ -343,7 +343,7 @@ class ComputeTestCase(test.TestCase):
self.compute.resume_instance(self.context, instance_id) self.compute.resume_instance(self.context, instance_id)
self.compute.terminate_instance(self.context, instance_id) self.compute.terminate_instance(self.context, instance_id)
def test_soft_reboot_api(self): def test_reboot_soft_api(self):
"""Ensure instance can be soft rebooted""" """Ensure instance can be soft rebooted"""
instance_id = self._create_instance() instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id) self.compute.run_instance(self.context, instance_id)
@@ -352,14 +352,14 @@ class ComputeTestCase(test.TestCase):
self.assertEqual(inst_ref['task_state'], None) self.assertEqual(inst_ref['task_state'], None)
reboot_type = "SOFT" reboot_type = "SOFT"
self.compute_api.reboot(self.context, instance_id, reboot_type) self.compute_api.reboot(self.context, inst_ref, reboot_type)
inst_ref = db.instance_get(self.context, instance_id) inst_ref = db.instance_get(self.context, instance_id)
self.assertEqual(inst_ref['task_state'], task_states.REBOOTING) self.assertEqual(inst_ref['task_state'], task_states.REBOOTING)
db.instance_destroy(self.context, instance_id) db.instance_destroy(self.context, instance_id)
def test_soft_reboot(self): def test_reboot_soft(self):
"""Ensure instance can be soft rebooted""" """Ensure instance can be soft rebooted"""
instance_id = self._create_instance() instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id) self.compute.run_instance(self.context, instance_id)
@@ -375,7 +375,7 @@ class ComputeTestCase(test.TestCase):
self.compute.terminate_instance(self.context, instance_id) self.compute.terminate_instance(self.context, instance_id)
def test_hard_reboot_api(self): def test_reboot_hard_api(self):
"""Ensure instance can be hard rebooted""" """Ensure instance can be hard rebooted"""
instance_id = self._create_instance() instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id) self.compute.run_instance(self.context, instance_id)
@@ -384,14 +384,14 @@ class ComputeTestCase(test.TestCase):
self.assertEqual(inst_ref['task_state'], None) self.assertEqual(inst_ref['task_state'], None)
reboot_type = "HARD" reboot_type = "HARD"
self.compute_api.reboot(self.context, instance_id, reboot_type) self.compute_api.reboot(self.context, inst_ref, reboot_type)
inst_ref = db.instance_get(self.context, instance_id) inst_ref = db.instance_get(self.context, instance_id)
self.assertEqual(inst_ref['task_state'], task_states.REBOOTING_HARD) self.assertEqual(inst_ref['task_state'], task_states.REBOOTING_HARD)
db.instance_destroy(self.context, instance_id) db.instance_destroy(self.context, instance_id)
def test_hard_reboot(self): def test_reboot_hard(self):
"""Ensure instance can be hard rebooted""" """Ensure instance can be hard rebooted"""
instance_id = self._create_instance() instance_id = self._create_instance()
self.compute.run_instance(self.context, instance_id) self.compute.run_instance(self.context, instance_id)