summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/compute/manager.py14
-rw-r--r--nova/tests/test_virt_drivers.py26
-rw-r--r--nova/tests/test_vmwareapi.py23
-rw-r--r--nova/tests/test_xenapi.py4
-rw-r--r--nova/virt/driver.py12
-rw-r--r--nova/virt/fake.py12
-rw-r--r--nova/virt/libvirt/connection.py12
-rw-r--r--nova/virt/vmwareapi/vmops.py21
-rw-r--r--nova/virt/vmwareapi_conn.py16
-rw-r--r--nova/virt/xenapi/vmops.py32
-rw-r--r--nova/virt/xenapi_conn.py24
11 files changed, 83 insertions, 113 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 2fc2972bf..f133ee133 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -901,8 +901,7 @@ class ComputeManager(manager.SchedulerDependentManager):
utils.generate_password(FLAGS.password_length))
network_info = self._get_instance_nw_info(context, instance_ref)
- # NOTE(blamar): None of the virt drivers use the 'callback' param
- self.driver.rescue(context, instance_ref, None, network_info)
+ self.driver.rescue(context, instance_ref, network_info)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
@@ -921,8 +920,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref = self.db.instance_get(context, instance_id)
network_info = self._get_instance_nw_info(context, instance_ref)
- # NOTE(blamar): None of the virt drivers use the 'callback' param
- self.driver.unrescue(instance_ref, None, network_info)
+ self.driver.unrescue(instance_ref, network_info)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
@@ -1174,7 +1172,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
- self.driver.pause(instance_ref, lambda result: None)
+ self.driver.pause(instance_ref)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
@@ -1191,7 +1189,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
- self.driver.unpause(instance_ref, lambda result: None)
+ self.driver.unpause(instance_ref)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
@@ -1227,7 +1225,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
- self.driver.suspend(instance_ref, lambda result: None)
+ self.driver.suspend(instance_ref)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
@@ -1244,7 +1242,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id)
- self.driver.resume(instance_ref, lambda result: None)
+ self.driver.resume(instance_ref)
current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context,
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index be77dab2f..1550d64f3 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -153,24 +153,22 @@ class _VirtDriverTestCase(test.TestCase):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.rescue(self.ctxt, instance_ref,
- lambda x: None, network_info)
+ self.connection.rescue(self.ctxt, instance_ref, network_info)
@catch_notimplementederror
def test_unrescue_unrescued_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.unrescue(instance_ref, lambda x: None, network_info)
+ self.connection.unrescue(instance_ref, network_info)
@catch_notimplementederror
def test_unrescue_rescued_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.rescue(self.ctxt, instance_ref,
- lambda x: None, network_info)
- self.connection.unrescue(instance_ref, lambda x: None, network_info)
+ self.connection.rescue(self.ctxt, instance_ref, network_info)
+ self.connection.unrescue(instance_ref, network_info)
@catch_notimplementederror
def test_poll_rebooting_instances(self):
@@ -197,44 +195,44 @@ class _VirtDriverTestCase(test.TestCase):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.pause(instance_ref, None)
+ self.connection.pause(instance_ref)
@catch_notimplementederror
def test_unpause_unpaused_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.unpause(instance_ref, None)
+ self.connection.unpause(instance_ref)
@catch_notimplementederror
def test_unpause_paused_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.pause(instance_ref, None)
- self.connection.unpause(instance_ref, None)
+ self.connection.pause(instance_ref)
+ self.connection.unpause(instance_ref)
@catch_notimplementederror
def test_suspend(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.suspend(instance_ref, None)
+ self.connection.suspend(instance_ref)
@catch_notimplementederror
def test_resume_unsuspended_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.resume(instance_ref, None)
+ self.connection.resume(instance_ref)
@catch_notimplementederror
def test_resume_suspended_instance(self):
instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info)
- self.connection.suspend(instance_ref, None)
- self.connection.resume(instance_ref, None)
+ self.connection.suspend(instance_ref)
+ self.connection.resume(instance_ref)
@catch_notimplementederror
def test_destroy_instance_nonexistant(self):
diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py
index e6da1690f..704e362fd 100644
--- a/nova/tests/test_vmwareapi.py
+++ b/nova/tests/test_vmwareapi.py
@@ -183,7 +183,7 @@ class VMWareAPIVMTestCase(test.TestCase):
self._create_vm()
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
- self.conn.suspend(self.instance, self.dummy_callback_handler)
+ self.conn.suspend(self.instance)
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED)
self.assertRaises(Exception, self.conn.reboot, self.instance)
@@ -192,37 +192,34 @@ class VMWareAPIVMTestCase(test.TestCase):
self._create_vm()
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
- self.conn.suspend(self.instance, self.dummy_callback_handler)
+ self.conn.suspend(self.instance)
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED)
def test_suspend_non_existent(self):
self._create_instance_in_the_db()
- self.assertRaises(Exception, self.conn.suspend, self.instance,
- self.dummy_callback_handler)
+ self.assertRaises(Exception, self.conn.suspend, self.instance)
def test_resume(self):
self._create_vm()
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
- self.conn.suspend(self.instance, self.dummy_callback_handler)
+ self.conn.suspend(self.instance)
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED)
- self.conn.resume(self.instance, self.dummy_callback_handler)
+ self.conn.resume(self.instance)
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
def test_resume_non_existent(self):
self._create_instance_in_the_db()
- self.assertRaises(Exception, self.conn.resume, self.instance,
- self.dummy_callback_handler)
+ self.assertRaises(Exception, self.conn.resume, self.instance)
def test_resume_not_suspended(self):
self._create_vm()
info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING)
- self.assertRaises(Exception, self.conn.resume, self.instance,
- self.dummy_callback_handler)
+ self.assertRaises(Exception, self.conn.resume, self.instance)
def test_get_info(self):
self._create_vm()
@@ -258,9 +255,3 @@ class VMWareAPIVMTestCase(test.TestCase):
def test_get_ajax_console(self):
pass
-
- def dummy_callback_handler(self, ret):
- """
- Dummy callback function to be passed to suspend, resume, etc., calls.
- """
- pass
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index e2ed14495..c807186e1 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -654,13 +654,13 @@ class XenAPIVMTestCase(test.TestCase):
def test_rescue(self):
instance = self._create_instance()
conn = xenapi_conn.get_connection(False)
- conn.rescue(self.context, instance, None, [])
+ conn.rescue(self.context, instance, [])
def test_unrescue(self):
instance = self._create_instance()
conn = xenapi_conn.get_connection(False)
# Ensure that it will not unrescue a non-rescued instance.
- self.assertRaises(Exception, conn.unrescue, instance, None)
+ self.assertRaises(Exception, conn.unrescue, instance)
def test_finish_revert_migration(self):
instance = self._create_instance()
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index 8e2a28758..6bd83fb4d 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"""