Browse Source

Strip final dot of the fqdn hostname and dnsname

Not all services support an FQDN ending with a dot.

Closes-Bug: #1928869
Change-Id: I6b1de8815796b76150f4fed97b7e15dc9adcbbfe
(cherry picked from commit bac04330bb)
changes/87/792887/1
Harald Jensås 2 months ago
parent
commit
99ec07c516
  1. 10
      tripleo_common/inventory.py
  2. 2
      tripleo_common/tests/fake_neutron/fakes.py
  3. 44
      tripleo_common/tests/test_inventory.py

10
tripleo_common/inventory.py

@ -143,6 +143,11 @@ class NeutronData(object):
raise exception.MissingMandatoryNeutronResourceTag()
hostname = port.dns_name
# Strip the final fqdn dot of the hostname
# See: https://bugs.launchpad.net/tripleo/+bug/1928869
if hostname.endswith('.'):
hostname = hostname[:-1]
network_id = port.network_id
network = self.networks_by_id[network_id]
fixed_ips = port.fixed_ips[0]
@ -152,6 +157,11 @@ class NeutronData(object):
# "TripleO" cidr is the number of bits in the network mask
cidr = subnet['cidr'].split('/')[1]
dns_domain = network['dns_domain']
# Strip the final fqdn dot of the dnsname
# See: https://bugs.launchpad.net/tripleo/+bug/1928869
if dns_domain.endswith('.'):
dns_domain = dns_domain[:-1]
dns_nameservers = subnet['dns_nameservers']
mtu = network['mtu']
net_name = network['name']

2
tripleo_common/tests/fake_neutron/fakes.py

@ -28,7 +28,7 @@ internal_api_network = stubs.FakeNeutronNetwork(
name='internal_api',
id='internal_api_network_id',
mtu=1500,
dns_domain='internalapi.example.com',
dns_domain='internalapi.example.com.',
subnet_ids=['internal_api_subnet_id'],
tags=['tripleo_net_idx=0',
'tripleo_vip=true',

44
tripleo_common/tests/test_inventory.py

@ -756,8 +756,8 @@ class TestInventory(base.TestCase):
('Compute',
{'hosts': {
'ansible_host': '192.0.2.20',
'canonical_hostname': 'cp-0.example.com.',
'ctlplane_hostname': 'cp-0.ctlplane.example.com.',
'canonical_hostname': 'cp-0.example.com',
'ctlplane_hostname': 'cp-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.20',
'internal_api_hostname': 'cp-0.internalapi.example.com',
'internal_api_ip': '198.51.100.150'},
@ -796,15 +796,15 @@ class TestInventory(base.TestCase):
{'hosts': {
'c-0': {
'ansible_host': '192.0.2.10',
'canonical_hostname': 'c-0.example.com.',
'ctlplane_hostname': 'c-0.ctlplane.example.com.',
'canonical_hostname': 'c-0.example.com',
'ctlplane_hostname': 'c-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.10',
'internal_api_hostname': 'c-0.internalapi.example.com',
'internal_api_ip': '198.51.100.140'},
'c-1': {
'ansible_host': '192.0.2.11',
'canonical_hostname': 'c-1.example.com.',
'ctlplane_hostname': 'c-1.ctlplane.example.com.',
'canonical_hostname': 'c-1.example.com',
'ctlplane_hostname': 'c-1.ctlplane.example.com',
'ctlplane_ip': '192.0.2.11',
'internal_api_hostname': 'c-1.internalapi.example.com',
'internal_api_ip': '198.51.100.141'}},
@ -836,8 +836,8 @@ class TestInventory(base.TestCase):
{'hosts': {
'cp-0': {
'ansible_host': '192.0.2.20',
'canonical_hostname': 'cp-0.example.com.',
'ctlplane_hostname': 'cp-0.ctlplane.example.com.',
'canonical_hostname': 'cp-0.example.com',
'ctlplane_hostname': 'cp-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.20',
'internal_api_hostname': 'cp-0.internalapi.example.com',
'internal_api_ip': '198.51.100.150'}},
@ -1021,24 +1021,24 @@ class TestInventory(base.TestCase):
'hosts': {
'c-0': {
'ansible_host': '192.0.2.10',
'canonical_hostname': 'c-0.example.com.',
'ctlplane_hostname': 'c-0.ctlplane.example.com.',
'canonical_hostname': 'c-0.example.com',
'ctlplane_hostname': 'c-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.10',
'deploy_server_id': 'a',
'internal_api_hostname': 'c-0.internalapi.example.com',
'internal_api_ip': '198.51.100.140'},
'c-1': {
'ansible_host': '192.0.2.11',
'canonical_hostname': 'c-1.example.com.',
'ctlplane_hostname': 'c-1.ctlplane.example.com.',
'canonical_hostname': 'c-1.example.com',
'ctlplane_hostname': 'c-1.ctlplane.example.com',
'ctlplane_ip': '192.0.2.11',
'deploy_server_id': 'b',
'internal_api_hostname': 'c-1.internalapi.example.com',
'internal_api_ip': '198.51.100.141'},
'c-2': {
'ansible_host': '192.0.2.12',
'canonical_hostname': 'c-2.example.com.',
'ctlplane_hostname': 'c-2.ctlplane.example.com.',
'canonical_hostname': 'c-2.example.com',
'ctlplane_hostname': 'c-2.ctlplane.example.com',
'ctlplane_ip': '192.0.2.12',
'deploy_server_id': 'c',
'internal_api_hostname': 'c-2.internalapi.example.com',
@ -1072,8 +1072,8 @@ class TestInventory(base.TestCase):
'hosts': {
'cp-0': {
'ansible_host': '192.0.2.20',
'canonical_hostname': 'cp-0.example.com.',
'ctlplane_hostname': 'cp-0.ctlplane.example.com.',
'canonical_hostname': 'cp-0.example.com',
'ctlplane_hostname': 'cp-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.20',
'deploy_server_id': 'd',
'internal_api_hostname':
@ -1108,8 +1108,8 @@ class TestInventory(base.TestCase):
'hosts': {
'cs-0': {
'ansible_host': '192.0.2.200',
'canonical_hostname': 'cs-0.example.com.',
'ctlplane_hostname': 'cs-0.ctlplane.example.com.',
'canonical_hostname': 'cs-0.example.com',
'ctlplane_hostname': 'cs-0.ctlplane.example.com',
'ctlplane_ip': '192.0.2.200',
'deploy_server_id': 'e'}},
'vars': {'ansible_ssh_user': 'heat-admin',
@ -1278,7 +1278,7 @@ class TestNeutronData(base.TestCase):
'subnet_ids': ['ctlplane_subnet_id'],
'tags': {}},
'internal_api_network_id': {
'dns_domain': 'internalapi.example.com',
'dns_domain': 'internalapi.example.com.',
'mtu': 1500,
'name': 'internal_api',
'name_upper': 'InternalApi',
@ -1328,7 +1328,7 @@ class TestNeutronData(base.TestCase):
cmp_0 = cmp_role['cp-0']
self.assertEqual(
[{'cidr': '24',
'dns_domain': 'ctlplane.example.com.',
'dns_domain': 'ctlplane.example.com',
'dns_nameservers': ['192.0.2.253', '192.0.2.254'],
'fixed_ips': [{'ip_address': '192.0.2.10',
'subnet_id': 'ctlplane_subnet_id'}],
@ -1369,7 +1369,7 @@ class TestNeutronData(base.TestCase):
)
self.assertEqual(
[{'cidr': '24',
'dns_domain': 'ctlplane.example.com.',
'dns_domain': 'ctlplane.example.com',
'dns_nameservers': ['192.0.2.253', '192.0.2.254'],
'fixed_ips': [{'ip_address': '192.0.2.11',
'subnet_id': 'ctlplane_subnet_id'}],
@ -1410,7 +1410,7 @@ class TestNeutronData(base.TestCase):
)
self.assertEqual(
[{'cidr': '24',
'dns_domain': 'ctlplane.example.com.',
'dns_domain': 'ctlplane.example.com',
'dns_nameservers': ['192.0.2.253', '192.0.2.254'],
'fixed_ips': [{'ip_address': '192.0.2.20',
'subnet_id': 'ctlplane_subnet_id'}],

Loading…
Cancel
Save