Don't write files to /etc/init if not present
Only write the libvirt-bin.override file if /etc/init actually exists; This is really present to support upstart based deployments so is not required on Ubuntu Xenial or later. If nova-compute is deployed in a LXD container, this directory is unlikely to be present in a pristine container image. Change-Id: Ie68be0f3e7ca610478159f5f1dd491b8b755e82e Closes-Bug: 1805191
This commit is contained in:
parent
9ff97e429d
commit
ade7586da4
|
@ -337,6 +337,12 @@ def resource_map():
|
|||
enable_nova_metadata, _ = nova_metadata_requirement()
|
||||
if enable_nova_metadata:
|
||||
resource_map[NOVA_CONF]['services'].append('nova-api-metadata')
|
||||
|
||||
# NOTE(james-page): If not on an upstart based system, don't write
|
||||
# and override file for libvirt-bin.
|
||||
if not os.path.exists('/etc/init'):
|
||||
del resource_map[LIBVIRT_BIN_OVERRIDES]
|
||||
|
||||
return resource_map
|
||||
|
||||
|
||||
|
|
|
@ -223,13 +223,16 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
result = utils.determine_packages()
|
||||
self.assertTrue('nova-api-metadata' in result)
|
||||
|
||||
@patch.object(utils, 'os')
|
||||
@patch.object(utils, 'nova_metadata_requirement')
|
||||
@patch.object(utils, 'network_manager')
|
||||
def test_resource_map_nova_network_no_multihost(self, net_man, en_meta):
|
||||
def test_resource_map_nova_network_no_multihost(self, net_man, en_meta,
|
||||
_os):
|
||||
self.os_release.return_value = 'icehouse'
|
||||
self.test_config.set('multi-host', 'no')
|
||||
en_meta.return_value = (False, None)
|
||||
net_man.return_value = 'flatdhcpmanager'
|
||||
_os.path.exists.return_value = True
|
||||
result = utils.resource_map()
|
||||
ex = {
|
||||
'/etc/default/libvirt-bin': {
|
||||
|
@ -277,13 +280,15 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
self.assertEqual(set(ex[k]['services']),
|
||||
set(result[k]['services']))
|
||||
|
||||
@patch.object(utils, 'os')
|
||||
@patch.object(utils, 'nova_metadata_requirement')
|
||||
@patch.object(utils, 'network_manager')
|
||||
def test_resource_map_nova_network_ocata(self, net_man, en_meta):
|
||||
def test_resource_map_nova_network_ocata(self, net_man, en_meta, _os):
|
||||
self.os_release.return_value = 'ocata'
|
||||
self.test_config.set('multi-host', 'yes')
|
||||
en_meta.return_value = (False, None)
|
||||
net_man.return_value = 'flatdhcpmanager'
|
||||
_os.path.exists.return_value = False
|
||||
result = utils.resource_map()
|
||||
ex = {
|
||||
'/etc/default/libvirt-bin': {
|
||||
|
@ -310,10 +315,6 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
'contexts': [],
|
||||
'services': ['qemu-kvm']
|
||||
},
|
||||
'/etc/init/libvirt-bin.override': {
|
||||
'contexts': [],
|
||||
'services': ['libvirtd']
|
||||
},
|
||||
'/etc/libvirt/libvirtd.conf': {
|
||||
'contexts': [],
|
||||
'services': ['libvirtd']
|
||||
|
@ -331,14 +332,16 @@ class NovaComputeUtilsTests(CharmTestCase):
|
|||
self.assertEqual(set(ex[k]['services']),
|
||||
set(result[k]['services']))
|
||||
|
||||
@patch.object(utils, 'os')
|
||||
@patch.object(utils, 'nova_metadata_requirement')
|
||||
@patch.object(utils, 'network_manager')
|
||||
def test_resource_map_nova_network(self, net_man, en_meta):
|
||||
def test_resource_map_nova_network(self, net_man, en_meta, _os):
|
||||
|
||||
self.os_release.return_value = 'icehouse'
|
||||
en_meta.return_value = (False, None)
|
||||
self.test_config.set('multi-host', 'yes')
|
||||
net_man.return_value = 'flatdhcpmanager'
|
||||
_os.path.exists.return_value = True
|
||||
result = utils.resource_map()
|
||||
|
||||
ex = {
|
||||
|
|
Loading…
Reference in New Issue