Skip to content

Commit

Permalink
Merge "Implements resume_state_on_host_boot for libvirt." into stable…
Browse files Browse the repository at this point in the history
…/essex
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 14, 2012
2 parents a8328f0 + 27133ee commit 0c2b4f6
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 2 deletions.
10 changes: 8 additions & 2 deletions nova/compute/manager.py
Expand Up @@ -246,15 +246,21 @@ def init_host(self):
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:
# Hyper-V and 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:
Expand Down
6 changes: 6 additions & 0 deletions nova/tests/test_virt_drivers.py
Expand Up @@ -142,6 +142,12 @@ def test_agent_update(self):
self.connection.agent_update(instance_ref, 'http://www.openstack.org/',
'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()
Expand Down
4 changes: 4 additions & 0 deletions nova/virt/driver.py
Expand Up @@ -335,6 +335,10 @@ def resume(self, instance):
# 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()
Expand Down
3 changes: 3 additions & 0 deletions nova/virt/fake.py
Expand Up @@ -131,6 +131,9 @@ def inject_file(self, instance, b64_path, b64_contents):
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

Expand Down
7 changes: 7 additions & 0 deletions nova/virt/libvirt/connection.py
Expand Up @@ -824,6 +824,13 @@ def resume(self, instance):
dom = self._lookup_by_name(instance.name)
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.
Expand Down

0 comments on commit 0c2b4f6

Please sign in to comment.