diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-08 15:30:25 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-08 15:30:25 +0000 |
| commit | d6f9b26ca3ff01ecef45e61e8fd473106dec3d86 (patch) | |
| tree | 71c732436120a36f80a3dd6176cc7ebc4f882d84 | |
| parent | d8165400ac5ccb61142c12af1346cf41edc31cc4 (diff) | |
| parent | d5d2df5718fae936d8c3f852be2fdc81b7789870 (diff) | |
| download | nova-d6f9b26ca3ff01ecef45e61e8fd473106dec3d86.tar.gz nova-d6f9b26ca3ff01ecef45e61e8fd473106dec3d86.tar.xz nova-d6f9b26ca3ff01ecef45e61e8fd473106dec3d86.zip | |
Merge "Adding task_states.REBOOTING_HARD"
| -rw-r--r-- | nova/api/openstack/common.py | 1 | ||||
| -rw-r--r-- | nova/compute/api.py | 4 | ||||
| -rw-r--r-- | nova/compute/manager.py | 3 | ||||
| -rw-r--r-- | nova/compute/task_states.py | 1 | ||||
| -rw-r--r-- | nova/tests/api/openstack/test_servers.py | 5 | ||||
| -rw-r--r-- | nova/tests/test_compute.py | 52 |
6 files changed, 61 insertions, 5 deletions
diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index 0f3f1fff7..9db50d790 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -46,6 +46,7 @@ _STATE_MAP = { vm_states.ACTIVE: { 'default': 'ACTIVE', task_states.REBOOTING: 'REBOOT', + task_states.REBOOTING_HARD: 'HARD_REBOOT', task_states.UPDATING_PASSWORD: 'PASSWORD', task_states.RESIZE_VERIFY: 'VERIFY_RESIZE', }, diff --git a/nova/compute/api.py b/nova/compute/api.py index 0d6498693..297803e09 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1180,10 +1180,12 @@ class API(base.Base): @scheduler_api.reroute_compute("reboot") def reboot(self, context, instance_id, reboot_type): """Reboot the given instance.""" + state = {'SOFT': task_states.REBOOTING, + 'HARD': task_states.REBOOTING_HARD}[reboot_type] self.update(context, instance_id, vm_state=vm_states.ACTIVE, - task_state=task_states.REBOOTING) + task_state=state) self._cast_compute_message('reboot_instance', context, instance_id, params={'reboot_type': reboot_type}) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 4a51147a2..af1c5e473 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -680,8 +680,7 @@ class ComputeManager(manager.SchedulerDependentManager): self._instance_update(context, instance_id, power_state=current_power_state, - vm_state=vm_states.ACTIVE, - task_state=task_states.REBOOTING) + vm_state=vm_states.ACTIVE) if instance_ref['power_state'] != power_state.RUNNING: state = instance_ref['power_state'] diff --git a/nova/compute/task_states.py b/nova/compute/task_states.py index b52140bf8..c6016b509 100644 --- a/nova/compute/task_states.py +++ b/nova/compute/task_states.py @@ -46,6 +46,7 @@ RESIZE_VERIFY = 'resize_verify' REBUILDING = 'rebuilding' REBOOTING = 'rebooting' +REBOOTING_HARD = 'rebooting_hard' PAUSING = 'pausing' UNPAUSING = 'unpausing' SUSPENDING = 'suspending' diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 31c87e630..d7f44ddd1 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -1306,6 +1306,11 @@ class ServerStatusTest(test.TestCase): task_states.REBOOTING) self.assertEqual(response['server']['status'], 'REBOOT') + def test_reboot_hard(self): + response = self._get_with_state(vm_states.ACTIVE, + task_states.REBOOTING_HARD) + self.assertEqual(response['server']['status'], 'HARD_REBOOT') + def test_rebuild(self): response = self._get_with_state(vm_states.REBUILDING) self.assertEqual(response['server']['status'], 'REBUILD') diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b235bcade..479fd4647 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -342,20 +342,68 @@ class ComputeTestCase(test.TestCase): self.compute.resume_instance(self.context, instance_id) self.compute.terminate_instance(self.context, instance_id) - def test_soft_reboot(self): + def test_soft_reboot_api(self): """Ensure instance can be soft rebooted""" instance_id = self._create_instance() + self.compute.run_instance(self.context, instance_id) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['task_state'], None) + reboot_type = "SOFT" + self.compute_api.reboot(self.context, instance_id, reboot_type) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['task_state'], task_states.REBOOTING) + + db.instance_destroy(self.context, instance_id) + + def test_soft_reboot(self): + """Ensure instance can be soft rebooted""" + instance_id = self._create_instance() self.compute.run_instance(self.context, instance_id) + db.instance_update(self.context, instance_id, + {'task_state': task_states.REBOOTING}) + + reboot_type = "SOFT" self.compute.reboot_instance(self.context, instance_id, reboot_type) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['power_state'], power_state.RUNNING) + self.assertEqual(inst_ref['task_state'], None) + self.compute.terminate_instance(self.context, instance_id) - def test_hard_reboot(self): + def test_hard_reboot_api(self): """Ensure instance can be hard rebooted""" instance_id = self._create_instance() + self.compute.run_instance(self.context, instance_id) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['task_state'], None) + reboot_type = "HARD" + self.compute_api.reboot(self.context, instance_id, reboot_type) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['task_state'], task_states.REBOOTING_HARD) + + db.instance_destroy(self.context, instance_id) + + def test_hard_reboot(self): + """Ensure instance can be hard rebooted""" + instance_id = self._create_instance() self.compute.run_instance(self.context, instance_id) + db.instance_update(self.context, instance_id, + {'task_state': task_states.REBOOTING_HARD}) + + reboot_type = "HARD" self.compute.reboot_instance(self.context, instance_id, reboot_type) + + inst_ref = db.instance_get(self.context, instance_id) + self.assertEqual(inst_ref['power_state'], power_state.RUNNING) + self.assertEqual(inst_ref['task_state'], None) + self.compute.terminate_instance(self.context, instance_id) def test_set_admin_password(self): |
