diff options
| author | Brian Lamar <brian.lamar@rackspace.com> | 2011-10-25 17:15:49 -0500 |
|---|---|---|
| committer | Brian Lamar <brian.lamar@rackspace.com> | 2011-10-25 17:17:40 -0500 |
| commit | e8b0ff71faef4268669deb035f711de394fb0e78 (patch) | |
| tree | 626318e56b27a8785dfb678816c3735d9c0020c5 /nova/virt | |
| parent | ace2628dfa6048a8e8b7757daefffc1987cfad3f (diff) | |
Removed callback concept on VM driver methods:
* pause
* unpause
* suspend
* resume
* rescue
* unrescue
Worked off blueprint remove-virt-driver-callbacks
Change-Id: Ie3ef4c8155320f72106d7a39e5817516e180ba52
Diffstat (limited to 'nova/virt')
| -rw-r--r-- | nova/virt/driver.py | 12 | ||||
| -rw-r--r-- | nova/virt/fake.py | 12 | ||||
| -rw-r--r-- | nova/virt/libvirt/connection.py | 12 | ||||
| -rw-r--r-- | nova/virt/vmwareapi/vmops.py | 21 | ||||
| -rw-r--r-- | nova/virt/vmwareapi_conn.py | 16 | ||||
| -rw-r--r-- | nova/virt/xenapi/vmops.py | 32 | ||||
| -rw-r--r-- | nova/virt/xenapi_conn.py | 24 |
7 files changed, 56 insertions, 73 deletions
diff --git a/nova/virt/driver.py b/nova/virt/driver.py index 88a239002..e002c4e0a 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -271,31 +271,31 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def pause(self, instance, callback): + def pause(self, instance): """Pause the specified instance.""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def unpause(self, instance, callback): + def unpause(self, instance): """Unpause paused VM instance""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def suspend(self, instance, callback): + def suspend(self, instance): """suspend the specified instance""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def resume(self, instance, callback): + def resume(self, instance): """resume the specified instance""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def rescue(self, context, instance, callback, network_info): + def rescue(self, context, instance, network_info): """Rescue the specified instance""" raise NotImplementedError() - def unrescue(self, instance, callback, network_info): + def unrescue(self, instance, network_info): """Unrescue the specified instance""" # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index 6b70be2bc..446d784a0 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -125,10 +125,10 @@ class FakeConnection(driver.ComputeDriver): def agent_update(self, instance, url, md5hash): pass - def rescue(self, context, instance, callback, network_info): + def rescue(self, context, instance, network_info): pass - def unrescue(self, instance, callback, network_info): + def unrescue(self, instance, network_info): pass def poll_rebooting_instances(self, timeout): @@ -143,16 +143,16 @@ class FakeConnection(driver.ComputeDriver): def poll_unconfirmed_resizes(self, resize_confirm_window): pass - def pause(self, instance, callback): + def pause(self, instance): pass - def unpause(self, instance, callback): + def unpause(self, instance): pass - def suspend(self, instance, callback): + def suspend(self, instance): pass - def resume(self, instance, callback): + def resume(self, instance): pass def destroy(self, instance, network_info, block_device_info=None, diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index ebb2e0c85..3e39482d8 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -550,31 +550,31 @@ class LibvirtConnection(driver.ComputeDriver): return timer.start(interval=0.5, now=True) @exception.wrap_exception() - def pause(self, instance, callback): + def pause(self, instance): """Pause VM instance""" dom = self._lookup_by_name(instance.name) dom.suspend() @exception.wrap_exception() - def unpause(self, instance, callback): + def unpause(self, instance): """Unpause paused VM instance""" dom = self._lookup_by_name(instance.name) dom.resume() @exception.wrap_exception() - def suspend(self, instance, callback): + def suspend(self, instance): """Suspend the specified instance""" dom = self._lookup_by_name(instance.name) dom.managedSave(0) @exception.wrap_exception() - def resume(self, instance, callback): + def resume(self, instance): """resume the specified instance""" dom = self._lookup_by_name(instance.name) dom.create() @exception.wrap_exception() - def rescue(self, context, instance, callback, network_info): + def rescue(self, context, instance, network_info): """Loads a VM using rescue images. A rescue is normally performed when something goes wrong with the @@ -604,7 +604,7 @@ class LibvirtConnection(driver.ComputeDriver): self.reboot(instance, network_info, xml=xml) @exception.wrap_exception() - def unrescue(self, instance, callback, network_info): + def unrescue(self, instance, network_info): """Reboot the VM which is being rescued back into primary images. Because reboot destroys and re-creates instances, unresue should diff --git a/nova/virt/vmwareapi/vmops.py b/nova/virt/vmwareapi/vmops.py index 063b84a62..b4cb7f037 100644 --- a/nova/virt/vmwareapi/vmops.py +++ b/nova/virt/vmwareapi/vmops.py @@ -58,15 +58,6 @@ class VMWareVMOps(object): self._session = session
self._vif_driver = utils.import_object(FLAGS.vmware_vif_driver)
- def _wait_with_callback(self, instance_id, task, callback):
- """Waits for the task to finish and does a callback after."""
- ret = None
- try:
- ret = self._session._wait_for_task(instance_id, task)
- except Exception, excep:
- LOG.exception(excep)
- callback(ret)
-
def list_instances(self):
"""Lists the VM instances that are registered with the ESX host."""
LOG.debug(_("Getting list of instances"))
@@ -615,15 +606,15 @@ class VMWareVMOps(object): except Exception, exc:
LOG.exception(exc)
- def pause(self, instance, callback):
+ def pause(self, instance):
"""Pause a VM instance."""
raise exception.ApiError("pause not supported for vmwareapi")
- def unpause(self, instance, callback):
+ def unpause(self, instance):
"""Un-Pause a VM instance."""
raise exception.ApiError("unpause not supported for vmwareapi")
- def suspend(self, instance, callback):
+ def suspend(self, instance):
"""Suspend the specified instance."""
vm_ref = self._get_vm_ref_from_the_name(instance.name)
if vm_ref is None:
@@ -637,7 +628,7 @@ class VMWareVMOps(object): LOG.debug(_("Suspending the VM %s ") % instance.name)
suspend_task = self._session._call_method(self._session._get_vim(),
"SuspendVM_Task", vm_ref)
- self._wait_with_callback(instance.id, suspend_task, callback)
+ self._session._wait_for_task(instance.id, suspend_task)
LOG.debug(_("Suspended the VM %s ") % instance.name)
# Raise Exception if VM is poweredOff
elif pwr_state == "poweredOff":
@@ -647,7 +638,7 @@ class VMWareVMOps(object): LOG.debug(_("VM %s was already in suspended state. So returning "
"without doing anything") % instance.name)
- def resume(self, instance, callback):
+ def resume(self, instance):
"""Resume the specified instance."""
vm_ref = self._get_vm_ref_from_the_name(instance.name)
if vm_ref is None:
@@ -661,7 +652,7 @@ class VMWareVMOps(object): suspend_task = self._session._call_method(
self._session._get_vim(),
"PowerOnVM_Task", vm_ref)
- self._wait_with_callback(instance.id, suspend_task, callback)
+ self._session._wait_for_task(instance.id, suspend_task)
LOG.debug(_("Resumed the VM %s ") % instance.name)
else:
reason = _("instance is not in a suspended state")
diff --git a/nova/virt/vmwareapi_conn.py b/nova/virt/vmwareapi_conn.py index 12e542390..bef8b00f8 100644 --- a/nova/virt/vmwareapi_conn.py +++ b/nova/virt/vmwareapi_conn.py @@ -142,21 +142,21 @@ class VMWareESXConnection(driver.ComputeDriver): """Destroy VM instance."""
self._vmops.destroy(instance, network_info)
- def pause(self, instance, callback):
+ def pause(self, instance):
"""Pause VM instance."""
- self._vmops.pause(instance, callback)
+ self._vmops.pause(instance)
- def unpause(self, instance, callback):
+ def unpause(self, instance):
"""Unpause paused VM instance."""
- self._vmops.unpause(instance, callback)
+ self._vmops.unpause(instance)
- def suspend(self, instance, callback):
+ def suspend(self, instance):
"""Suspend the specified instance."""
- self._vmops.suspend(instance, callback)
+ self._vmops.suspend(instance)
- def resume(self, instance, callback):
+ def resume(self, instance):
"""Resume the suspended VM instance."""
- self._vmops.resume(instance, callback)
+ self._vmops.resume(instance)
def get_info(self, instance_id):
"""Return info about the VM instance."""
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index c7b519887..93b4ae153 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -1057,40 +1057,32 @@ class VMOps(object): for (network, mapping) in network_info: self.vif_driver.unplug(instance, network, mapping) - def _wait_with_callback(self, instance_id, task, callback): - ret = None - try: - ret = self._session.wait_for_task(task, instance_id) - except self.XenAPI.Failure, exc: - LOG.exception(exc) - callback(ret) - - def pause(self, instance, callback): + def pause(self, instance): """Pause VM instance.""" vm_ref = self._get_vm_opaque_ref(instance) task = self._session.call_xenapi('Async.VM.pause', vm_ref) - self._wait_with_callback(instance.id, task, callback) + self._session.wait_for_task(task, instance.id) - def unpause(self, instance, callback): + def unpause(self, instance): """Unpause VM instance.""" vm_ref = self._get_vm_opaque_ref(instance) task = self._session.call_xenapi('Async.VM.unpause', vm_ref) - self._wait_with_callback(instance.id, task, callback) + self._session.wait_for_task(task, instance.id) - def suspend(self, instance, callback): + def suspend(self, instance): """Suspend the specified instance.""" vm_ref = self._get_vm_opaque_ref(instance) task = self._session.call_xenapi('Async.VM.suspend', vm_ref) - self._wait_with_callback(instance.id, task, callback) + self._session.wait_for_task(task, instance.id) - def resume(self, instance, callback): + def resume(self, instance): """Resume the specified instance.""" vm_ref = self._get_vm_opaque_ref(instance) - task = self._session.call_xenapi('Async.VM.resume', vm_ref, False, - True) - self._wait_with_callback(instance.id, task, callback) + task = self._session.call_xenapi('Async.VM.resume', + vm_ref, False, True) + self._session.wait_for_task(task, instance.id) - def rescue(self, context, instance, _callback, network_info): + def rescue(self, context, instance, network_info): """Rescue the specified instance. - shutdown the instance VM. @@ -1114,7 +1106,7 @@ class VMOps(object): self._session.call_xenapi("Async.VBD.plug", rescue_vbd_ref) - def unrescue(self, instance, _callback): + def unrescue(self, instance): """Unrescue the specified instance. - unplug the instance VM's disk from the rescue VM. diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index 7fb57d967..0aa8d45a5 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -236,34 +236,34 @@ class XenAPIConnection(driver.ComputeDriver): """Destroy VM instance""" self._vmops.destroy(instance, network_info) - def pause(self, instance, callback): + def pause(self, instance): """Pause VM instance""" - self._vmops.pause(instance, callback) + self._vmops.pause(instance) - def unpause(self, instance, callback): + def unpause(self, instance): """Unpause paused VM instance""" - self._vmops.unpause(instance, callback) + self._vmops.unpause(instance) def migrate_disk_and_power_off(self, context, instance, dest): """Transfers the VHD of a running instance to another host, then shuts off the instance copies over the COW disk""" return self._vmops.migrate_disk_and_power_off(context, instance, dest) - def suspend(self, instance, callback): + def suspend(self, instance): """suspend the specified instance""" - self._vmops.suspend(instance, callback) + self._vmops.suspend(instance) - def resume(self, instance, callback): + def resume(self, instance): """resume the specified instance""" - self._vmops.resume(instance, callback) + self._vmops.resume(instance) - def rescue(self, context, instance, _callback, network_info): + def rescue(self, context, instance, network_info): """Rescue the specified instance""" - self._vmops.rescue(context, instance, _callback, network_info) + self._vmops.rescue(context, instance, network_info) - def unrescue(self, instance, _callback, network_info): + def unrescue(self, instance, network_info): """Unrescue the specified instance""" - self._vmops.unrescue(instance, _callback) + self._vmops.unrescue(instance) def power_off(self, instance): """Power off the specified instance""" |
