Merge "Implemented resume_state_on_host_boot driver callback"

This commit is contained in:
Jenkins 2017-08-24 10:58:12 +00:00 committed by Gerrit Code Review
commit e968708f66
2 changed files with 34 additions and 0 deletions

View File

@ -950,6 +950,23 @@ class LXDDriverTest(test.NoDBTestCase):
self.client.containers.get.assert_called_once_with(instance.name)
container.unfreeze.assert_called_once_with(wait=True)
def test_resume_state_on_host_boot(self):
container = mock.Mock()
state = mock.Mock()
state.memory = dict({'usage': 0, 'usage_peak': 0})
state.status_code = 102
container.state.return_value = state
self.client.containers.get.return_value = container
ctx = context.get_admin_context()
instance = fake_instance.fake_instance_obj(
ctx, name='test', memory_mb=0)
lxd_driver = driver.LXDDriver(None)
lxd_driver.init_host(None)
lxd_driver.resume_state_on_host_boot(ctx, instance, None, None)
container.start.assert_called_once_with(wait=True)
def test_rescue(self):
profile = mock.Mock()
profile.devices = {

View File

@ -869,6 +869,23 @@ class LXDDriver(driver.ComputeDriver):
"""
self.unpause(instance)
def resume_state_on_host_boot(self, context, instance, network_info,
block_device_info=None):
"""resume guest state when a host is booted."""
try:
state = self.get_info(instance).state
ignored_states = (power_state.RUNNING,
power_state.SUSPENDED,
power_state.NOSTATE,
power_state.PAUSED)
if state in ignored_states:
return
self.power_on(context, instance, network_info, block_device_info)
except (exception.InternalError, exception.InstanceNotFound):
pass
def rescue(self, context, instance, network_info, image_meta,
rescue_password):
"""Rescue a LXD container.