summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-06-01 02:52:57 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2012-06-06 15:17:44 -0700
commit7c847bc659e7c493cf009adc417be2e884c3c616 (patch)
tree2042f2b65e03a3e6c6358671cd6b57443ffffeff /nova/virt
parentae878fc8b9761d099a4145617e4a48cbeb390623 (diff)
Cleans up power_off and power_on semantics
compute.api changes: * improves state handling for delete/restrore * removes hack to deal with SHUTOFF on start * fixes api tests (volume shouldn't detach on stop) compute.manager changes: * uses power_off/power_on for stop/start virt.libvirt changes: * implements power_off/power_on for libvirt * synchronizes usage of domain.create() * cleans up usage of instance.name * added tests for power_on and power_off * fixes bug 1006950 Change-Id: I91845a643e3f97955e7c81ca57c6ee5aa0a3d295
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/fake.py6
-rw-r--r--nova/virt/libvirt/connection.py31
2 files changed, 28 insertions, 9 deletions
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 316a7769a..0e7a4c1e3 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -139,6 +139,12 @@ class FakeDriver(driver.ComputeDriver):
def finish_revert_migration(self, instance, network_info):
pass
+ def power_off(self, instance):
+ pass
+
+ def power_on(self, instance):
+ pass
+
def pause(self, instance):
pass
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 34729aeed..5c2077897 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -718,7 +718,7 @@ class LibvirtDriver(driver.ComputeDriver):
finally:
libvirt_utils.delete_snapshot(disk_path, snapshot_name)
if state == power_state.RUNNING:
- virt_dom.create()
+ self._create_domain(domain=virt_dom)
# Upload that image to the image service
with libvirt_utils.file_open(out_path) as image_file:
@@ -770,7 +770,7 @@ class LibvirtDriver(driver.ComputeDriver):
power_state.CRASHED]:
LOG.info(_("Instance shutdown successfully."),
instance=instance)
- dom.create()
+ self._create_domain(domain=dom)
timer = utils.LoopingCall(self._wait_for_running, instance)
return timer.start(interval=0.5)
greenthread.sleep(1)
@@ -808,26 +808,39 @@ class LibvirtDriver(driver.ComputeDriver):
@exception.wrap_exception()
def pause(self, instance):
"""Pause VM instance"""
- dom = self._lookup_by_name(instance.name)
+ dom = self._lookup_by_name(instance['name'])
dom.suspend()
@exception.wrap_exception()
def unpause(self, instance):
"""Unpause paused VM instance"""
- dom = self._lookup_by_name(instance.name)
+ dom = self._lookup_by_name(instance['name'])
dom.resume()
@exception.wrap_exception()
+ def power_off(self, instance):
+ """Power off the specified instance"""
+ self._destroy(instance)
+
+ @exception.wrap_exception()
+ def power_on(self, instance):
+ """Power on the specified instance"""
+ dom = self._lookup_by_name(instance['name'])
+ self._create_domain(domain=dom)
+ timer = utils.LoopingCall(self._wait_for_running, instance)
+ return timer.start(interval=0.5)
+
+ @exception.wrap_exception()
def suspend(self, instance):
"""Suspend the specified instance"""
- dom = self._lookup_by_name(instance.name)
+ dom = self._lookup_by_name(instance['name'])
dom.managedSave(0)
@exception.wrap_exception()
def resume(self, instance):
"""resume the specified instance"""
- dom = self._lookup_by_name(instance.name)
- dom.create()
+ dom = self._lookup_by_name(instance['name'])
+ self._create_domain(domain=dom)
@exception.wrap_exception()
def resume_state_on_host_boot(self, context, instance, network_info):
@@ -2253,7 +2266,7 @@ class LibvirtDriver(driver.ComputeDriver):
post_method(ctxt, instance_ref, dest, block_migration)
timer.f = wait_for_live_migration
- timer.start(interval=0.5)
+ return timer.start(interval=0.5)
def pre_live_migration(self, block_device_info):
"""Preparation live migration.
@@ -2505,7 +2518,7 @@ class LibvirtDriver(driver.ComputeDriver):
disk_info_text = self.get_instance_disk_info(instance['name'])
disk_info = jsonutils.loads(disk_info_text)
- self._destroy(instance)
+ self.power_off(instance)
# copy disks to destination
# if disk type is qcow2, convert to raw then send to dest.