Fix gate for enabling FQDN agent registration
If a new version of the charm is used to install a version of OpenStack prior to Stein, do not enable the FQDN registration. Change-Id: I64afa582cdfadafcd249ddfbeec267ba610d166a Closes-Bug: #1846781
This commit is contained in:
parent
b44bf586b8
commit
ed4ca7b1c4
|
@ -620,7 +620,8 @@ class HostIPContext(context.OSContextGenerator):
|
|||
# We do want to migrate to using FQDNs so we enable this for new
|
||||
# installations.
|
||||
db = kv()
|
||||
if (db.get('install_version', 0) >= 1910 and cmp_release >= 'stein' and
|
||||
if (db.get('neutron-ovs-charm-use-fqdn', False) and
|
||||
cmp_release >= 'stein' and
|
||||
host_ip):
|
||||
fqdn = socket.getfqdn(host_ip)
|
||||
if '.' in fqdn:
|
||||
|
|
|
@ -82,9 +82,13 @@ CONFIGS = register_configs()
|
|||
def install():
|
||||
install_packages()
|
||||
|
||||
db = kv()
|
||||
db.set('install_version', 1910)
|
||||
db.flush()
|
||||
# Start migration to agent registration with FQDNs for newly installed
|
||||
# units with OpenStack release Stein or newer.
|
||||
release = os_release('neutron-common')
|
||||
if CompareOpenStackReleases(release) >= 'stein':
|
||||
db = kv()
|
||||
db.set('neutron-ovs-charm-use-fqdn', True)
|
||||
db.flush()
|
||||
|
||||
|
||||
# NOTE(wolsen): Do NOT add restart_on_change decorator without consideration
|
||||
|
|
|
@ -1001,7 +1001,7 @@ class TestHostIPContext(CharmTestCase):
|
|||
_getfqdn.return_value = 'some.hostname'
|
||||
ctxt = context.HostIPContext()
|
||||
self.assertDictEqual({}, ctxt())
|
||||
_kv.return_value = {'install_version': 1910}
|
||||
_kv.return_value = {'neutron-ovs-charm-use-fqdn': True}
|
||||
ctxt = context.HostIPContext()
|
||||
self.assertDictEqual({'host': 'some.hostname'}, ctxt())
|
||||
_os_release.return_value = 'rocky'
|
||||
|
|
|
@ -71,14 +71,19 @@ class NeutronOVSHooksTests(CharmTestCase):
|
|||
hooks.hooks.execute([
|
||||
'hooks/{}'.format(hookname)])
|
||||
|
||||
@patch.object(hooks, 'os_release')
|
||||
@patch.object(hooks, 'kv')
|
||||
def test_install_hook(self, _kv):
|
||||
def test_install_hook(self, _kv, _os_release):
|
||||
fake_dict = MagicMock()
|
||||
_kv.return_value = fake_dict
|
||||
_os_release.return_value = 'rocky'
|
||||
self._call_hook('install')
|
||||
self.install_packages.assert_called_with()
|
||||
_os_release.return_value = 'stein'
|
||||
self._call_hook('install')
|
||||
_kv.assert_called_once_with()
|
||||
fake_dict.set.assert_called_once_with('install_version', 1910)
|
||||
fake_dict.set.assert_called_once_with(
|
||||
'neutron-ovs-charm-use-fqdn', True)
|
||||
|
||||
@patch('neutron_ovs_hooks.enable_sriov', MagicMock(return_value=False))
|
||||
@patch.object(hooks, 'restart_map')
|
||||
|
|
Loading…
Reference in New Issue