Removed callback concept on VM driver methods:

* pause
 * unpause
 * suspend
 * resume
 * rescue
 * unrescue

Worked off blueprint remove-virt-driver-callbacks

Change-Id: Ie3ef4c8155320f72106d7a39e5817516e180ba52
This commit is contained in:
Brian Lamar
2011-10-25 17:15:49 -05:00
parent ace2628dfa
commit e8b0ff71fa
11 changed files with 83 additions and 113 deletions

View File

@@ -901,8 +901,7 @@ class ComputeManager(manager.SchedulerDependentManager):
utils.generate_password(FLAGS.password_length)) utils.generate_password(FLAGS.password_length))
network_info = self._get_instance_nw_info(context, instance_ref) 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, network_info)
self.driver.rescue(context, instance_ref, None, network_info)
current_power_state = self._get_power_state(context, instance_ref) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,
@@ -921,8 +920,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance_ref = self.db.instance_get(context, instance_id) instance_ref = self.db.instance_get(context, instance_id)
network_info = self._get_instance_nw_info(context, instance_ref) 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, network_info)
self.driver.unrescue(instance_ref, None, network_info)
current_power_state = self._get_power_state(context, instance_ref) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,
@@ -1174,7 +1172,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated() context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id) 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) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,
@@ -1191,7 +1189,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated() context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id) 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) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,
@@ -1227,7 +1225,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated() context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id) 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) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,
@@ -1244,7 +1242,7 @@ class ComputeManager(manager.SchedulerDependentManager):
context = context.elevated() context = context.elevated()
instance_ref = self.db.instance_get(context, instance_id) 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) current_power_state = self._get_power_state(context, instance_ref)
self._instance_update(context, self._instance_update(context,

View File

@@ -153,24 +153,22 @@ class _VirtDriverTestCase(test.TestCase):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.rescue(self.ctxt, instance_ref, self.connection.rescue(self.ctxt, instance_ref, network_info)
lambda x: None, network_info)
@catch_notimplementederror @catch_notimplementederror
def test_unrescue_unrescued_instance(self): def test_unrescue_unrescued_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, 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 @catch_notimplementederror
def test_unrescue_rescued_instance(self): def test_unrescue_rescued_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.rescue(self.ctxt, instance_ref, self.connection.rescue(self.ctxt, instance_ref, network_info)
lambda x: None, network_info) self.connection.unrescue(instance_ref, network_info)
self.connection.unrescue(instance_ref, lambda x: None, network_info)
@catch_notimplementederror @catch_notimplementederror
def test_poll_rebooting_instances(self): def test_poll_rebooting_instances(self):
@@ -197,44 +195,44 @@ class _VirtDriverTestCase(test.TestCase):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.pause(instance_ref, None) self.connection.pause(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_unpause_unpaused_instance(self): def test_unpause_unpaused_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.unpause(instance_ref, None) self.connection.unpause(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_unpause_paused_instance(self): def test_unpause_paused_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.pause(instance_ref, None) self.connection.pause(instance_ref)
self.connection.unpause(instance_ref, None) self.connection.unpause(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_suspend(self): def test_suspend(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.suspend(instance_ref, None) self.connection.suspend(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_resume_unsuspended_instance(self): def test_resume_unsuspended_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.resume(instance_ref, None) self.connection.resume(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_resume_suspended_instance(self): def test_resume_suspended_instance(self):
instance_ref = test_utils.get_test_instance() instance_ref = test_utils.get_test_instance()
network_info = test_utils.get_test_network_info() network_info = test_utils.get_test_network_info()
self.connection.spawn(self.ctxt, instance_ref, network_info) self.connection.spawn(self.ctxt, instance_ref, network_info)
self.connection.suspend(instance_ref, None) self.connection.suspend(instance_ref)
self.connection.resume(instance_ref, None) self.connection.resume(instance_ref)
@catch_notimplementederror @catch_notimplementederror
def test_destroy_instance_nonexistant(self): def test_destroy_instance_nonexistant(self):

View File

@@ -183,7 +183,7 @@ class VMWareAPIVMTestCase(test.TestCase):
self._create_vm() self._create_vm()
info = self.conn.get_info(1) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING) 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) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED) self._check_vm_info(info, power_state.PAUSED)
self.assertRaises(Exception, self.conn.reboot, self.instance) self.assertRaises(Exception, self.conn.reboot, self.instance)
@@ -192,37 +192,34 @@ class VMWareAPIVMTestCase(test.TestCase):
self._create_vm() self._create_vm()
info = self.conn.get_info(1) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING) 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) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED) self._check_vm_info(info, power_state.PAUSED)
def test_suspend_non_existent(self): def test_suspend_non_existent(self):
self._create_instance_in_the_db() self._create_instance_in_the_db()
self.assertRaises(Exception, self.conn.suspend, self.instance, self.assertRaises(Exception, self.conn.suspend, self.instance)
self.dummy_callback_handler)
def test_resume(self): def test_resume(self):
self._create_vm() self._create_vm()
info = self.conn.get_info(1) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING) 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) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.PAUSED) 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) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING) self._check_vm_info(info, power_state.RUNNING)
def test_resume_non_existent(self): def test_resume_non_existent(self):
self._create_instance_in_the_db() self._create_instance_in_the_db()
self.assertRaises(Exception, self.conn.resume, self.instance, self.assertRaises(Exception, self.conn.resume, self.instance)
self.dummy_callback_handler)
def test_resume_not_suspended(self): def test_resume_not_suspended(self):
self._create_vm() self._create_vm()
info = self.conn.get_info(1) info = self.conn.get_info(1)
self._check_vm_info(info, power_state.RUNNING) self._check_vm_info(info, power_state.RUNNING)
self.assertRaises(Exception, self.conn.resume, self.instance, self.assertRaises(Exception, self.conn.resume, self.instance)
self.dummy_callback_handler)
def test_get_info(self): def test_get_info(self):
self._create_vm() self._create_vm()
@@ -258,9 +255,3 @@ class VMWareAPIVMTestCase(test.TestCase):
def test_get_ajax_console(self): def test_get_ajax_console(self):
pass pass
def dummy_callback_handler(self, ret):
"""
Dummy callback function to be passed to suspend, resume, etc., calls.
"""
pass

View File

@@ -654,13 +654,13 @@ class XenAPIVMTestCase(test.TestCase):
def test_rescue(self): def test_rescue(self):
instance = self._create_instance() instance = self._create_instance()
conn = xenapi_conn.get_connection(False) conn = xenapi_conn.get_connection(False)
conn.rescue(self.context, instance, None, []) conn.rescue(self.context, instance, [])
def test_unrescue(self): def test_unrescue(self):
instance = self._create_instance() instance = self._create_instance()
conn = xenapi_conn.get_connection(False) conn = xenapi_conn.get_connection(False)
# Ensure that it will not unrescue a non-rescued instance. # 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): def test_finish_revert_migration(self):
instance = self._create_instance() instance = self._create_instance()

View File

@@ -271,31 +271,31 @@ class ComputeDriver(object):
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()
def pause(self, instance, callback): def pause(self, instance):
"""Pause the specified instance.""" """Pause the specified instance."""
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()
def unpause(self, instance, callback): def unpause(self, instance):
"""Unpause paused VM instance""" """Unpause paused VM instance"""
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()
def suspend(self, instance, callback): def suspend(self, instance):
"""suspend the specified instance""" """suspend the specified instance"""
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()
def resume(self, instance, callback): def resume(self, instance):
"""resume the specified instance""" """resume the specified instance"""
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()
def rescue(self, context, instance, callback, network_info): def rescue(self, context, instance, network_info):
"""Rescue the specified instance""" """Rescue the specified instance"""
raise NotImplementedError() raise NotImplementedError()
def unrescue(self, instance, callback, network_info): def unrescue(self, instance, network_info):
"""Unrescue the specified instance""" """Unrescue the specified instance"""
# TODO(Vek): Need to pass context in for access to auth_token # TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError() raise NotImplementedError()

View File

@@ -125,10 +125,10 @@ class FakeConnection(driver.ComputeDriver):
def agent_update(self, instance, url, md5hash): def agent_update(self, instance, url, md5hash):
pass pass
def rescue(self, context, instance, callback, network_info): def rescue(self, context, instance, network_info):
pass pass
def unrescue(self, instance, callback, network_info): def unrescue(self, instance, network_info):
pass pass
def poll_rebooting_instances(self, timeout): def poll_rebooting_instances(self, timeout):
@@ -143,16 +143,16 @@ class FakeConnection(driver.ComputeDriver):
def poll_unconfirmed_resizes(self, resize_confirm_window): def poll_unconfirmed_resizes(self, resize_confirm_window):
pass pass
def pause(self, instance, callback): def pause(self, instance):
pass pass
def unpause(self, instance, callback): def unpause(self, instance):
pass pass
def suspend(self, instance, callback): def suspend(self, instance):
pass pass
def resume(self, instance, callback): def resume(self, instance):
pass pass
def destroy(self, instance, network_info, block_device_info=None, def destroy(self, instance, network_info, block_device_info=None,

View File

@@ -550,31 +550,31 @@ class LibvirtConnection(driver.ComputeDriver):
return timer.start(interval=0.5, now=True) return timer.start(interval=0.5, now=True)
@exception.wrap_exception() @exception.wrap_exception()
def pause(self, instance, callback): def pause(self, instance):
"""Pause VM instance""" """Pause VM instance"""
dom = self._lookup_by_name(instance.name) dom = self._lookup_by_name(instance.name)
dom.suspend() dom.suspend()
@exception.wrap_exception() @exception.wrap_exception()
def unpause(self, instance, callback): def unpause(self, instance):
"""Unpause paused VM instance""" """Unpause paused VM instance"""
dom = self._lookup_by_name(instance.name) dom = self._lookup_by_name(instance.name)
dom.resume() dom.resume()
@exception.wrap_exception() @exception.wrap_exception()
def suspend(self, instance, callback): def suspend(self, instance):
"""Suspend the specified instance""" """Suspend the specified instance"""
dom = self._lookup_by_name(instance.name) dom = self._lookup_by_name(instance.name)
dom.managedSave(0) dom.managedSave(0)
@exception.wrap_exception() @exception.wrap_exception()
def resume(self, instance, callback): def resume(self, instance):
"""resume the specified instance""" """resume the specified instance"""
dom = self._lookup_by_name(instance.name) dom = self._lookup_by_name(instance.name)
dom.create() dom.create()
@exception.wrap_exception() @exception.wrap_exception()
def rescue(self, context, instance, callback, network_info): def rescue(self, context, instance, network_info):
"""Loads a VM using rescue images. """Loads a VM using rescue images.
A rescue is normally performed when something goes wrong with the 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) self.reboot(instance, network_info, xml=xml)
@exception.wrap_exception() @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. """Reboot the VM which is being rescued back into primary images.
Because reboot destroys and re-creates instances, unresue should Because reboot destroys and re-creates instances, unresue should

View File

@@ -58,15 +58,6 @@ class VMWareVMOps(object):
self._session = session self._session = session
self._vif_driver = utils.import_object(FLAGS.vmware_vif_driver) 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): def list_instances(self):
"""Lists the VM instances that are registered with the ESX host.""" """Lists the VM instances that are registered with the ESX host."""
LOG.debug(_("Getting list of instances")) LOG.debug(_("Getting list of instances"))
@@ -615,15 +606,15 @@ class VMWareVMOps(object):
except Exception, exc: except Exception, exc:
LOG.exception(exc) LOG.exception(exc)
def pause(self, instance, callback): def pause(self, instance):
"""Pause a VM instance.""" """Pause a VM instance."""
raise exception.ApiError("pause not supported for vmwareapi") raise exception.ApiError("pause not supported for vmwareapi")
def unpause(self, instance, callback): def unpause(self, instance):
"""Un-Pause a VM instance.""" """Un-Pause a VM instance."""
raise exception.ApiError("unpause not supported for vmwareapi") raise exception.ApiError("unpause not supported for vmwareapi")
def suspend(self, instance, callback): def suspend(self, instance):
"""Suspend the specified instance.""" """Suspend the specified instance."""
vm_ref = self._get_vm_ref_from_the_name(instance.name) vm_ref = self._get_vm_ref_from_the_name(instance.name)
if vm_ref is None: if vm_ref is None:
@@ -637,7 +628,7 @@ class VMWareVMOps(object):
LOG.debug(_("Suspending the VM %s ") % instance.name) LOG.debug(_("Suspending the VM %s ") % instance.name)
suspend_task = self._session._call_method(self._session._get_vim(), suspend_task = self._session._call_method(self._session._get_vim(),
"SuspendVM_Task", vm_ref) "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) LOG.debug(_("Suspended the VM %s ") % instance.name)
# Raise Exception if VM is poweredOff # Raise Exception if VM is poweredOff
elif pwr_state == "poweredOff": elif pwr_state == "poweredOff":
@@ -647,7 +638,7 @@ class VMWareVMOps(object):
LOG.debug(_("VM %s was already in suspended state. So returning " LOG.debug(_("VM %s was already in suspended state. So returning "
"without doing anything") % instance.name) "without doing anything") % instance.name)
def resume(self, instance, callback): def resume(self, instance):
"""Resume the specified instance.""" """Resume the specified instance."""
vm_ref = self._get_vm_ref_from_the_name(instance.name) vm_ref = self._get_vm_ref_from_the_name(instance.name)
if vm_ref is None: if vm_ref is None:
@@ -661,7 +652,7 @@ class VMWareVMOps(object):
suspend_task = self._session._call_method( suspend_task = self._session._call_method(
self._session._get_vim(), self._session._get_vim(),
"PowerOnVM_Task", vm_ref) "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) LOG.debug(_("Resumed the VM %s ") % instance.name)
else: else:
reason = _("instance is not in a suspended state") reason = _("instance is not in a suspended state")

View File

@@ -142,21 +142,21 @@ class VMWareESXConnection(driver.ComputeDriver):
"""Destroy VM instance.""" """Destroy VM instance."""
self._vmops.destroy(instance, network_info) self._vmops.destroy(instance, network_info)
def pause(self, instance, callback): def pause(self, instance):
"""Pause VM 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.""" """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.""" """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.""" """Resume the suspended VM instance."""
self._vmops.resume(instance, callback) self._vmops.resume(instance)
def get_info(self, instance_id): def get_info(self, instance_id):
"""Return info about the VM instance.""" """Return info about the VM instance."""

View File

@@ -1057,40 +1057,32 @@ class VMOps(object):
for (network, mapping) in network_info: for (network, mapping) in network_info:
self.vif_driver.unplug(instance, network, mapping) self.vif_driver.unplug(instance, network, mapping)
def _wait_with_callback(self, instance_id, task, callback): def pause(self, instance):
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):
"""Pause VM instance.""" """Pause VM instance."""
vm_ref = self._get_vm_opaque_ref(instance) vm_ref = self._get_vm_opaque_ref(instance)
task = self._session.call_xenapi('Async.VM.pause', vm_ref) 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.""" """Unpause VM instance."""
vm_ref = self._get_vm_opaque_ref(instance) vm_ref = self._get_vm_opaque_ref(instance)
task = self._session.call_xenapi('Async.VM.unpause', vm_ref) 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.""" """Suspend the specified instance."""
vm_ref = self._get_vm_opaque_ref(instance) vm_ref = self._get_vm_opaque_ref(instance)
task = self._session.call_xenapi('Async.VM.suspend', vm_ref) 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.""" """Resume the specified instance."""
vm_ref = self._get_vm_opaque_ref(instance) vm_ref = self._get_vm_opaque_ref(instance)
task = self._session.call_xenapi('Async.VM.resume', vm_ref, False, task = self._session.call_xenapi('Async.VM.resume',
True) vm_ref, False, True)
self._wait_with_callback(instance.id, task, callback) 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. """Rescue the specified instance.
- shutdown the instance VM. - shutdown the instance VM.
@@ -1114,7 +1106,7 @@ class VMOps(object):
self._session.call_xenapi("Async.VBD.plug", rescue_vbd_ref) self._session.call_xenapi("Async.VBD.plug", rescue_vbd_ref)
def unrescue(self, instance, _callback): def unrescue(self, instance):
"""Unrescue the specified instance. """Unrescue the specified instance.
- unplug the instance VM's disk from the rescue VM. - unplug the instance VM's disk from the rescue VM.

View File

@@ -236,34 +236,34 @@ class XenAPIConnection(driver.ComputeDriver):
"""Destroy VM instance""" """Destroy VM instance"""
self._vmops.destroy(instance, network_info) self._vmops.destroy(instance, network_info)
def pause(self, instance, callback): def pause(self, instance):
"""Pause VM 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""" """Unpause paused VM instance"""
self._vmops.unpause(instance, callback) self._vmops.unpause(instance)
def migrate_disk_and_power_off(self, context, instance, dest): def migrate_disk_and_power_off(self, context, instance, dest):
"""Transfers the VHD of a running instance to another host, then shuts """Transfers the VHD of a running instance to another host, then shuts
off the instance copies over the COW disk""" off the instance copies over the COW disk"""
return self._vmops.migrate_disk_and_power_off(context, instance, dest) return self._vmops.migrate_disk_and_power_off(context, instance, dest)
def suspend(self, instance, callback): def suspend(self, instance):
"""suspend the specified 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""" """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""" """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""" """Unrescue the specified instance"""
self._vmops.unrescue(instance, _callback) self._vmops.unrescue(instance)
def power_off(self, instance): def power_off(self, instance):
"""Power off the specified instance""" """Power off the specified instance"""