diff options
| author | Josh Kearney <josh.kearney@rackspace.com> | 2011-01-17 12:21:08 -0600 |
|---|---|---|
| committer | Josh Kearney <josh.kearney@rackspace.com> | 2011-01-17 12:21:08 -0600 |
| commit | 3300e692b61dc53ac8ae3bfdbac5bb1019983feb (patch) | |
| tree | 8726b4c9730009ebb965a42039c9cbe49a3cf7d2 | |
| parent | 40565d190087200278048d871e4d07938fe8c4a1 (diff) | |
Add Start/Shutdown support to XenAPI
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index 96be17d8c..0e6018973 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -207,6 +207,25 @@ class VMOps(object): logging.debug(_("Finished snapshot and upload for VM %s"), instance) + def start(self, instance): + """Start a VM instance""" + vm = self._get_vm_opaque_ref(instance) + task = self._session.call_xenapi("Async.VM.start", vm, False, False) + self._session.wait_for_task(instance.id, task) + + def shutdown(self, instance, hard=True): + """Shutdown a VM instance""" + vm = self._get_vm_opaque_ref(instance) + if hard: + task = self._session.call_xenapi("Async.VM.hard_shutdown", vm) + else: + # TODO(jk0): clean_shutdown is only supported if XenTools is + # installed and running. What we want to do eventually is try + # this first, and only issue the hard_shutdown if clean_shutdown + # were to fail. + task = self._session.call_xenapi("Async.VM.clean_shutdown", vm) + self._session.wait_for_task(instance.id, task) + def reboot(self, instance): """Reboot VM instance""" vm = self._get_vm_opaque_ref(instance) @@ -320,11 +339,11 @@ class VMOps(object): def rescue(self, instance, callback): """Rescue the specified instance""" - return True + self.shutdown(instance) def unrescue(self, instance, callback): """Unrescue the specified instance""" - return True + self.start(instance) def get_info(self, instance): """Return data about VM instance""" |
