From 90ea8c2a99c1feb1c6f789d53f2f97eb0f8175e2 Mon Sep 17 00:00:00 2001 From: Tim Beale Date: Thu, 14 Feb 2019 15:38:54 +1300 Subject: [PATCH] selftest: Try to tie dns_hub IP mapping to Samba.pm better dns_hub.py maps the testenv realm to an IP and Samba.pm maps the testenv NetBIOS name to an IP. We need to keep the two places consistent, as we add or remove testenvs. This patch changes dns_hub.py so that it uses a similar hashmap to Samba.pm. We now have a hashmap with the same name in 2 different places, so hopefully that's easier to tie them together and keep them in sync. Signed-off-by: Tim Beale Reviewed-by: Andrew Bartlett --- selftest/target/dns_hub.py | 53 +++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/selftest/target/dns_hub.py b/selftest/target/dns_hub.py index e440e72577a..14a58b1c31c 100755 --- a/selftest/target/dns_hub.py +++ b/selftest/target/dns_hub.py @@ -83,30 +83,35 @@ class DnsHandler(sserver.BaseRequestHandler): return 'torture' if lname.endswith('torturedom.samba.example.com'): return 'torture' - if lname.endswith('adnonssdom.samba.example.com'): - return '127.0.0.17' - if lname.endswith('adnontlmdom.samba.example.com'): - return '127.0.0.18' - if lname.endswith('samba2000.example.com'): - return '127.0.0.25' - if lname.endswith('samba2003.example.com'): - return '127.0.0.26' - if lname.endswith('samba2008r2.example.com'): - return '127.0.0.27' - if lname.endswith('addom.samba.example.com'): - return '127.0.0.30' - if lname.endswith('sub.samba.example.com'): - return '127.0.0.31' - if lname.endswith('chgdcpassword.samba.example.com'): - return '127.0.0.32' - if lname.endswith('backupdom.samba.example.com'): - return '127.0.0.40' - if lname.endswith('renamedom.samba.example.com'): - return '127.0.0.42' - if lname.endswith('labdom.samba.example.com'): - return '127.0.0.43' - if lname.endswith('samba.example.com'): - return '127.0.0.21' + + # this maps the SOCKET_WRAPPER_DEFAULT_IFACE value (which is the + # last byte of the IP address) for the various testenv PDCs to the + # corresponding DNS realm. + # This should always match %testenv_iface_mapping in Samba.pm. + testenv_iface_mapping = { + 'adnonssdom.samba.example.com': 17, # addc_no_nss + 'adnontlmdom.samba.example.com': 18, # addc_no_ntlm + 'samba2000.example.com': 25, # dc5 + 'samba2003.example.com': 26, # dc6 + 'samba2008r2.example.com': 27, # dc7 + 'addom.samba.example.com': 30, # addc + 'sub.samba.example.com': 31, # localsubdc + 'chgdcpassword.samba.example.com': 32, # chgdcpass + 'backupdom.samba.example.com': 40, # backupfromdc + 'renamedom.samba.example.com': 42, # renamedc + 'labdom.samba.example.com': 43, # labdc + 'samba.example.com': 21, # localdc + } + + # sort the realms so we find the longest-match first + testenv_realms = sorted(testenv_iface_mapping.keys(), key=len) + testenv_realms.reverse() + + for realm in testenv_realms: + if lname.endswith(realm): + iface = testenv_iface_mapping[realm] + return '127.0.0.' + str(iface) + return None def handle(self):