Stop managing grub.cfg in Yoga
From yoga onwards the ironic-conductor manges the grub.conf. This change ensure that the charm stops managing it. This change also ensures that the file permissions are set correctly prior to the upgrade to Yoga. While developing this change it became apparent that the charm was missing the code to trigger an upgrade after a change in openstack-origin so this change corrects that. Closes-Bug: #1968871 Change-Id: Ie7ac1b0203d3a51cf3ff74ed8797be3f169cfd1c
This commit is contained in:
parent
73a5b90d40
commit
a3b68bd8df
|
@ -2,6 +2,7 @@ import os
|
|||
import shutil
|
||||
|
||||
import charmhelpers.core.host as ch_host
|
||||
import charmhelpers.contrib.openstack.utils as ch_utils
|
||||
|
||||
|
||||
_IRONIC_USER = "ironic"
|
||||
|
@ -55,6 +56,10 @@ class PXEBootBase(object):
|
|||
self.HTTP_SERVER_CONF: [self.HTTPD_SERVICE_NAME, ],
|
||||
}
|
||||
|
||||
def get_permission_override_map(self):
|
||||
return {
|
||||
self.GRUB_CFG: 0o660}
|
||||
|
||||
def determine_packages(self):
|
||||
default_packages = (
|
||||
self.PACKAGES + self.TFTP_PACKAGES + self.HTTPD_PACKAGES)
|
||||
|
@ -88,9 +93,27 @@ class PXEBootBase(object):
|
|||
self.HTTP_ROOT, _IRONIC_USER, _IRONIC_GROUP, chowntopdir=True)
|
||||
|
||||
|
||||
def get_pxe_config_class(charm_config):
|
||||
class PXEBootYoga(PXEBootBase):
|
||||
|
||||
def get_restart_map(self):
|
||||
# self.GRUB_CFG is now managed by the ironic conductor service. Remove
|
||||
# it from charm management
|
||||
return {
|
||||
self.TFTP_CONFIG: [self.TFTPD_SERVICE, ],
|
||||
self.MAP_FILE: [self.TFTPD_SERVICE, ],
|
||||
self.HTTP_SERVER_CONF: [self.HTTPD_SERVICE_NAME, ],
|
||||
}
|
||||
|
||||
|
||||
def get_pxe_config_class(charm_config, release):
|
||||
# We may need to make slight adjustments to package names and/or
|
||||
# configuration files, based on the version of Ubuntu we are installing
|
||||
# on. This function serves as a factory which will return an instance
|
||||
# of the proper class to the charm. For now we only have one class.
|
||||
return PXEBootBase(charm_config)
|
||||
# of the proper class to the charm.
|
||||
cmp_os_release = ch_utils.CompareOpenStackReleases(
|
||||
release
|
||||
)
|
||||
if cmp_os_release < 'yoga':
|
||||
return PXEBootBase(charm_config)
|
||||
else:
|
||||
return PXEBootYoga(charm_config)
|
||||
|
|
|
@ -224,7 +224,7 @@ class IronicConductorCharm(charms_openstack.charm.OpenStackCharm):
|
|||
def __init__(self, **kw):
|
||||
super().__init__(**kw)
|
||||
self.pxe_config = controller_utils.get_pxe_config_class(
|
||||
self.config)
|
||||
self.config, os_release(self.release_pkg))
|
||||
self._setup_pxe_config(self.pxe_config)
|
||||
self._setup_power_adapter_config()
|
||||
self._configure_defaults()
|
||||
|
@ -308,6 +308,8 @@ class IronicConductorCharm(charms_openstack.charm.OpenStackCharm):
|
|||
self.config["ironic_user"] = cfg.IRONIC_USER
|
||||
self.config["ironic_group"] = cfg.IRONIC_GROUP
|
||||
self.restart_map.update(cfg.get_restart_map())
|
||||
self.permission_override_map.update(
|
||||
cfg.get_permission_override_map())
|
||||
if cfg.HTTPD_SERVICE_NAME not in self.services:
|
||||
self.services.append(
|
||||
cfg.HTTPD_SERVICE_NAME)
|
||||
|
|
|
@ -21,6 +21,7 @@ charm.use_defaults(
|
|||
def render(*args):
|
||||
hookenv.log("about to call the render_configs with {}".format(args))
|
||||
with charm.provide_charm_instance() as ironic_charm:
|
||||
ironic_charm.upgrade_if_available(args)
|
||||
ironic_charm.render_with_interfaces(
|
||||
charm.optional_interfaces(args))
|
||||
ironic_charm.configure_tls()
|
||||
|
|
|
@ -21,18 +21,31 @@ import charmhelpers.core.host as ch_host
|
|||
|
||||
import charm.openstack.ironic.controller_utils as controller_utils
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
CompareOpenStackReleases,
|
||||
)
|
||||
|
||||
|
||||
class TestGetPXEBootClass(test_utils.PatchHelper):
|
||||
|
||||
def test_get_pxe_config_class(self):
|
||||
CompareOpenStackReleases.return_value = 'xena'
|
||||
self.patch_object(
|
||||
ch_host, 'get_distrib_codename')
|
||||
self.get_distrib_codename.return_value = "focal"
|
||||
charm_config = {}
|
||||
pxe_class = controller_utils.get_pxe_config_class(charm_config)
|
||||
pxe_class = controller_utils.get_pxe_config_class(charm_config, 'xena')
|
||||
self.assertTrue(
|
||||
isinstance(
|
||||
pxe_class, controller_utils.PXEBootBase))
|
||||
self.assertFalse(
|
||||
isinstance(
|
||||
pxe_class, controller_utils.PXEBootYoga))
|
||||
CompareOpenStackReleases.return_value = 'yoga'
|
||||
pxe_class = controller_utils.get_pxe_config_class(charm_config, 'yoga')
|
||||
self.assertTrue(
|
||||
isinstance(
|
||||
pxe_class, controller_utils.PXEBootYoga))
|
||||
|
||||
|
||||
class TestPXEBootBase(test_utils.PatchHelper):
|
||||
|
|
|
@ -189,6 +189,7 @@ class TestIronicCharm(test_utils.PatchHelper):
|
|||
expected)
|
||||
|
||||
def test_get_amqp_credentials(self):
|
||||
os_release.return_value = "yoga"
|
||||
cfg_data = {
|
||||
"rabbit-user": "ironic",
|
||||
"rabbit-vhost": "openstack",
|
||||
|
@ -196,12 +197,13 @@ class TestIronicCharm(test_utils.PatchHelper):
|
|||
|
||||
hookenv.config.return_value = cfg_data
|
||||
target = ironic.IronicConductorCharm()
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data)
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data, 'yoga')
|
||||
|
||||
result = target.get_amqp_credentials()
|
||||
self.assertEqual(result, ('ironic', 'openstack'))
|
||||
|
||||
def test_get_database_setup(self):
|
||||
os_release.return_value = "yoga"
|
||||
cfg_data = {
|
||||
"database-user": "ironic",
|
||||
"database": "ironicdb",
|
||||
|
@ -209,7 +211,7 @@ class TestIronicCharm(test_utils.PatchHelper):
|
|||
|
||||
hookenv.config.return_value = cfg_data
|
||||
target = ironic.IronicConductorCharm()
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data)
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data, 'yoga')
|
||||
|
||||
result = target.get_database_setup()
|
||||
self.assertEqual(
|
||||
|
@ -219,22 +221,24 @@ class TestIronicCharm(test_utils.PatchHelper):
|
|||
"username": cfg_data["database-user"]}])
|
||||
|
||||
def test_enabled_network_interfaces(self):
|
||||
os_release.return_value = "yoga"
|
||||
cfg_data = {
|
||||
"enabled-network-interfaces": "fake, fake2"}
|
||||
hookenv.config.return_value = cfg_data
|
||||
target = ironic.IronicConductorCharm()
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data)
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data, 'yoga')
|
||||
|
||||
self.assertEqual(
|
||||
target.enabled_network_interfaces,
|
||||
["fake", "fake2"])
|
||||
|
||||
def test_enabled_deploy_interfaces(self):
|
||||
os_release.return_value = "yoga"
|
||||
cfg_data = {
|
||||
"enabled-deploy-interfaces": "fake, fake2"}
|
||||
hookenv.config.return_value = cfg_data
|
||||
target = ironic.IronicConductorCharm()
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data)
|
||||
self.get_pxe_config_class.assert_called_with(cfg_data, 'yoga')
|
||||
|
||||
self.assertEqual(
|
||||
target.enabled_deploy_interfaces,
|
||||
|
|
Loading…
Reference in New Issue