Add an ability to configure resume_guests_state_on_host_boot

resume_guests_state_on_host_boot can be set to 'true' in order to
restore the state of instances after a nove-compute node is restarted.

Closes-Bug: 1515783

Change-Id: Ifa5347db123773fc07800d653a72ced14e3891ea
Signed-off-by: Dmitrii Shcherbakov <dmitrii.shcherbakov@canonical.com>
This commit is contained in:
Dmitrii Shcherbakov 2017-01-19 00:55:33 +03:00
parent 963afaf529
commit 1b9290d047
5 changed files with 27 additions and 2 deletions

View File

@ -346,3 +346,9 @@ options:
NOTE: Availability zones must be created manually using the
'openstack aggregate create' command.
.
resume-guests-state-on-host-boot:
type: boolean
default: False
description: |
This option determines whether to start guests that were running
before the host rebooted

View File

@ -233,6 +233,8 @@ class NovaComputeVirtContext(context.OSContextGenerator):
if lsb_release()['DISTRIB_CODENAME'].lower() >= "yakkety":
ctxt['virt_type'] = config('virt-type')
ctxt['enable_live_migration'] = config('enable-live-migration')
ctxt['resume_guests_state_on_host_boot'] =\
config('resume-guests-state-on-host-boot')
return ctxt

View File

@ -134,6 +134,10 @@ pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
default_availability_zone = {{ default_availability_zone }}
{% endif -%}
{% if resume_guests_state_on_host_boot -%}
resume_guests_state_on_host_boot = {{ resume_guests_state_on_host_boot }}
{% endif -%}
{% if network_manager == 'neutron' and network_manager_config -%}
[neutron]
url = {{ network_manager_config.neutron_url }}

View File

@ -135,6 +135,11 @@ pci_passthrough_whitelist = {{ pci_passthrough_whitelist }}
default_availability_zone = {{ default_availability_zone }}
{% endif -%}
{% if resume_guests_state_on_host_boot -%}
resume_guests_state_on_host_boot = {{ resume_guests_state_on_host_boot }}
{% endif -%}
{% if network_manager == 'neutron' and network_manager_config -%}
[neutron]
url = {{ network_manager_config.neutron_url }}

View File

@ -272,7 +272,7 @@ class NovaComputeContextTests(CharmTestCase):
self.test_config.set('virt-type', 'lxd')
lxd = context.NovaComputeVirtContext()
self.assertEqual({}, lxd())
self.assertEqual({'resume_guests_state_on_host_boot': False}, lxd())
def test_lxd_live_migration_opts_yakkety(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
@ -282,7 +282,15 @@ class NovaComputeContextTests(CharmTestCase):
lxd = context.NovaComputeVirtContext()
self.assertEqual(
{'enable_live_migration': True, 'virt_type': 'lxd'}, lxd())
{'enable_live_migration': True,
'resume_guests_state_on_host_boot': False,
'virt_type': 'lxd'}, lxd())
def test_resume_guests_state_on_host_boot(self):
self.kv.return_value = FakeUnitdata(**{'host_uuid': self.host_uuid})
self.test_config.set('resume-guests-state-on-host-boot', True)
lxd = context.NovaComputeVirtContext()
self.assertEqual({'resume_guests_state_on_host_boot': True}, lxd())
@patch.object(context.uuid, 'uuid4')
def test_libvirt_new_uuid(self, mock_uuid):