diff options
| author | Chris Behrens <cbehrens@codestud.com> | 2012-07-07 21:38:36 -0700 |
|---|---|---|
| committer | Chris Behrens <cbehrens@codestud.com> | 2012-07-08 05:43:48 +0000 |
| commit | a97de51e017c9c07eaa3e4a9ddde4193e9528373 (patch) | |
| tree | 51a88ab226de81c38120796880fe061ee7190c18 /nova/virt | |
| parent | 642ec634c3beeb69175d0df12bcec8833e7efae5 (diff) | |
Make reboot work for halted xenapi instances
Fixes bug 1022199
This also will catch exceptions and make sure to reset the task_state,
while still generating an instance fault.
Change-Id: I122a1422b8e5731bc484414736ab44e60d4c9830
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/xenapi/fake.py | 12 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 18 |
2 files changed, 25 insertions, 5 deletions
diff --git a/nova/virt/xenapi/fake.py b/nova/virt/xenapi/fake.py index 72008a69d..050b696f0 100644 --- a/nova/virt/xenapi/fake.py +++ b/nova/virt/xenapi/fake.py @@ -536,8 +536,18 @@ class SessionBase(object): VDI_resize = VDI_resize_online + def _VM_reboot(self, session, vm_ref): + db_ref = _db_content['VM'][vm_ref] + if db_ref['power_state'] != 'Running': + raise Failure(['VM_BAD_POWER_STATE', + 'fake-opaque-ref', db_ref['power_state'].lower(), 'halted']) + db_ref['power_state'] = 'Running' + def VM_clean_reboot(self, session, vm_ref): - pass + return self._VM_reboot(session, vm_ref) + + def VM_hard_reboot(self, session, vm_ref): + return self._VM_reboot(session, vm_ref) def VM_hard_shutdown(self, session, vm_ref): db_ref = _db_content['VM'][vm_ref] diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 6af2ac9e0..5d445e0a6 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -843,10 +843,20 @@ class VMOps(object): # remove existing filters vm_ref = self._get_vm_opaque_ref(instance) - if reboot_type == "HARD": - self._session.call_xenapi('VM.hard_reboot', vm_ref) - else: - self._session.call_xenapi('VM.clean_reboot', vm_ref) + try: + if reboot_type == "HARD": + self._session.call_xenapi('VM.hard_reboot', vm_ref) + else: + self._session.call_xenapi('VM.clean_reboot', vm_ref) + except self._session.XenAPI.Failure, exc: + details = exc.details + if (details[0] == 'VM_BAD_POWER_STATE' and + details[-1] == 'halted'): + LOG.info(_("Starting halted instance found during reboot"), + instance=instance) + self._session.call_xenapi('VM.start', vm_ref, False, False) + return + raise def _get_agent_version(self, instance): """Get the version of the agent running on the VM instance.""" |
