summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-06-06 21:49:38 +0000
committerGerrit Code Review <review@openstack.org>2012-06-06 21:49:38 +0000
commit66a7b1895dcf0b7b4ad133edeec3d04205e75c41 (patch)
tree32c3c19ed5761722c44097ad2b5a11245369c83c
parent534e6cf87338d7d47349d6186e622ba73ecb9e40 (diff)
parent6548c509f1780a7168f26de6f2045ec7d5768520 (diff)
downloadnova-66a7b1895dcf0b7b4ad133edeec3d04205e75c41.tar.gz
nova-66a7b1895dcf0b7b4ad133edeec3d04205e75c41.tar.xz
nova-66a7b1895dcf0b7b4ad133edeec3d04205e75c41.zip
Merge "Implements resume_state_on_host_boot for libvirt."
-rw-r--r--nova/compute/manager.py10
-rw-r--r--nova/tests/test_virt_drivers.py6
-rw-r--r--nova/virt/driver.py4
-rw-r--r--nova/virt/fake.py3
-rw-r--r--nova/virt/libvirt/connection.py7
5 files changed, 28 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index a110401bc..2776ee230 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -287,15 +287,21 @@ class ComputeManager(manager.SchedulerDependentManager):
LOG.debug(_('Current state is %(drv_state)s, state in DB is '
'%(db_state)s.'), locals(), instance=instance)
+ net_info = self._get_instance_nw_info(context, instance)
if ((expect_running and FLAGS.resume_guests_state_on_host_boot) or
FLAGS.start_guests_on_host_boot):
LOG.info(_('Rebooting instance after nova-compute restart.'),
locals(), instance=instance)
- self.reboot_instance(context, instance['uuid'])
+ try:
+ self.driver.resume_state_on_host_boot(context, instance,
+ self._legacy_nw_info(net_info))
+ except NotImplementedError:
+ LOG.warning(_('Hypervisor driver does not support '
+ 'resume guests'), instance=instance)
+
elif drv_state == power_state.RUNNING:
# VMWareAPI drivers will raise an exception
try:
- net_info = self._get_instance_nw_info(context, instance)
self.driver.ensure_filtering_rules_for_instance(instance,
self._legacy_nw_info(net_info))
except NotImplementedError:
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index 87684ec59..d4be2b463 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -139,6 +139,12 @@ class _VirtDriverTestCase(test.TestCase):
'd41d8cd98f00b204e9800998ecf8427e')
@catch_notimplementederror
+ def test_resume_state_on_host_boot(self):
+ instance_ref, network_info = self._get_running_instance()
+ self.connection.resume_state_on_host_boot(self.ctxt, instance_ref,
+ network_info)
+
+ @catch_notimplementederror
def test_rescue(self):
instance_ref, network_info = self._get_running_instance()
self.connection.rescue(self.ctxt, instance_ref, network_info, None)
diff --git a/nova/virt/driver.py b/nova/virt/driver.py
index 895a32ed3..f7dfbf7cd 100644
--- a/nova/virt/driver.py
+++ b/nova/virt/driver.py
@@ -326,6 +326,10 @@ class ComputeDriver(object):
# TODO(Vek): Need to pass context in for access to auth_token
raise NotImplementedError()
+ def resume_state_on_host_boot(self, context, instance, network_info):
+ """resume guest state when a host is booted"""
+ raise NotImplementedError()
+
def rescue(self, context, instance, network_info, image_meta):
"""Rescue the specified instance"""
raise NotImplementedError()
diff --git a/nova/virt/fake.py b/nova/virt/fake.py
index 0ec705a53..316a7769a 100644
--- a/nova/virt/fake.py
+++ b/nova/virt/fake.py
@@ -117,6 +117,9 @@ class FakeDriver(driver.ComputeDriver):
def agent_update(self, instance, url, md5hash):
pass
+ def resume_state_on_host_boot(self, context, instance, network_info):
+ pass
+
def rescue(self, context, instance, network_info, image_meta):
pass
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index 0cfcf2993..a91ab26e9 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -840,6 +840,13 @@ class LibvirtDriver(driver.ComputeDriver):
dom.create()
@exception.wrap_exception()
+ def resume_state_on_host_boot(self, context, instance, network_info):
+ """resume guest state when a host is booted"""
+ # NOTE(dprince): use hard reboot to ensure network and firewall
+ # rules are configured
+ self._hard_reboot(instance, network_info)
+
+ @exception.wrap_exception()
def rescue(self, context, instance, network_info, image_meta):
"""Loads a VM using rescue images.