summaryrefslogtreecommitdiff
path: root/oslo_config/tests/test_types.py
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2020-08-18 15:30:04 +0200
committerDaniel Bengtsson <dbengt@redhat.com>2020-10-22 12:30:39 +0200
commit6480356928c9ae6169ea1e5a5b5f1df3d6e0dc75 (patch)
treedc3dc17d0801450b0e08e9abbccf4e8b23f90524 /oslo_config/tests/test_types.py
parentfcb88941e39a31e3ef6c5a930063da419431a7f6 (diff)
downloadoslo-config-6480356928c9ae6169ea1e5a5b5f1df3d6e0dc75.tar.gz
Add a new type HostDomain.
HostDomain is like HostAddress with the support of _ character - RFC1033 openstack services are failing to start when a hostname with underscore _ is provided. Example: ``` overcloud-novacompute_edge1-0.internalapi.localdomain overcloud-novacompute_edge1-0.internalapi ``` Nova use `HostAddressOpt` to define `live_migration_inbound_addr`, and if a hostname with underscore is present in the config file then the service fail to start. Example: ``` /etc/nova/nova.conf live_migration_inbound_addr = overcloud-novacompute_edge1-0.internalapi.localdomain ``` FQDN is a domain name that specifies its exact location in the tree hierarchy of the Domain Name System (DNS). Underscore are allowed by RFC1033 [1][2][3]. Indeed, while a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore.[1][2]. Systems such as DomainKeys and service records use the underscore. These changes allow us to use underscore with the `HostDomain`. [1] https://www.ietf.org/rfc/rfc1912.txt [2] https://www.ietf.org/rfc/rfc1033.txt [3] http://domainkeys.sourceforge.net/underscore.html Co-authored-by: Daniel Bengtsson <dbengt@redhat.com> Change-Id: I0a0670207f96a987996d329e5efa9a5eb2ce000c Closes-Bug: #1892044
Diffstat (limited to 'oslo_config/tests/test_types.py')
-rw-r--r--oslo_config/tests/test_types.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/oslo_config/tests/test_types.py b/oslo_config/tests/test_types.py
index 644a239..8ab4a09 100644
--- a/oslo_config/tests/test_types.py
+++ b/oslo_config/tests/test_types.py
@@ -766,6 +766,27 @@ class HostAddressTypeTests(TypeTestHelper, unittest.TestCase):
self.assertConvertedValue('abc.0-0', 'abc.0-0')
+class HostDomainTypeTests(TypeTestHelper, unittest.TestCase):
+ type = types.HostDomain()
+
+ def test_invalid_host_addresses(self):
+ self.assertInvalid('-1')
+ self.assertInvalid('3.14')
+ self.assertInvalid('10.0')
+ self.assertInvalid('host..name')
+ self.assertInvalid('org.10')
+ self.assertInvalid('0.0.00')
+
+ def test_valid_host_addresses(self):
+ self.assertConvertedValue('_foo', '_foo')
+ self.assertConvertedValue('host_name', 'host_name')
+ self.assertConvertedValue(
+ 'overcloud-novacompute_edge1-0.internalapi.localdomain',
+ 'overcloud-novacompute_edge1-0.internalapi.localdomain')
+ self.assertConvertedValue('host_01.co.uk', 'host_01.co.uk')
+ self.assertConvertedValue('_site01001', '_site01001')
+
+
class HostnameTypeTests(TypeTestHelper, unittest.TestCase):
type = types.Hostname()
@@ -796,8 +817,8 @@ class HostnameTypeTests(TypeTestHelper, unittest.TestCase):
self.assertInvalid("h'ost'")
self.assertInvalid("h'ost")
self.assertInvalid("h$ost")
- self.assertInvalid("h%ost")
self.assertInvalid("host_01.co.uk")
+ self.assertInvalid("h%ost")
self.assertInvalid("host;name=99")
self.assertInvalid('___site0.1001')
self.assertInvalid('_site01001')
@@ -808,6 +829,7 @@ class HostnameTypeTests(TypeTestHelper, unittest.TestCase):
def test_invalid_hostnames_with_numeric_characters(self):
self.assertInvalid("10.0.0.0")
self.assertInvalid("3.14")
+ self.assertInvalid('___site0.1001')
self.assertInvalid("org.10")
self.assertInvalid('0.0.00')