Test and record for ipv6 status for different hosts in Nagios
For each CE and SE, save also the ipv6 status - currently as 0:HostHasipv6address, 1:HostHasOnlyipv4Address and -1:NotAValidHost.
The xml feed from this can be used to populate a web page for the ipv6 WG to display the statuses of the different sites as seen by LHCb.
Merge request reports
Activity
54 54 55 55 return S_OK() 56 56 57 def isHostIPV6(host): May I suggest a slightly more pythonic way ?
In [19]: socket.getaddrinfo('storm-fe-lhcb.cr.cnaf.infn.it', None, socket.AF_INET6) Out[19]: [(10, 1, 6, '', ('2001:760:4205:128::128:74', 0, 0, 0)), (10, 2, 17, '', ('2001:760:4205:128::128:74', 0, 0, 0)), (10, 3, 0, '', ('2001:760:4205:128::128:74', 0, 0, 0))] In [20]: socket.getaddrinfo('tbit00.nipne.ro', None, socket.AF_INET6) --------------------------------------------------------------------------- gaierror Traceback (most recent call last) <ipython-input-20-02b8573f2095> in <module>() ----> 1 socket.getaddrinfo('tbit00.nipne.ro', None, socket.AF_INET6) gaierror: [Errno -2] Name or service not known
341 363 mappingSEFlavour = {'srm': 'SRMv2', 342 364 'root': 'XROOTD', 'http': 'HTTPS'} 343 365 344 xml_append(xml_doc, xml_site, 'service', 366 xml_se = xml_append(xml_doc, xml_site, 'service', 345 367 endpoint=site_se_endpoint, 346 368 flavour=mappingSEFlavour.get(site_se_flavour, 'UNDEFINED'), 347 369 hostname=site_se_name, 348 370 path=site_se_path) 349 371 372 # ipv6 status of the SE 54 55 55 56 return S_OK() 56 57 58 def contains(w, t): 59 """ A simple test to check for a string in a nested set of tuples""" 60 return any(w in str(x) for x in t) 61 62 def isHostIPV6(host): 63 """ Test if the given host is ipv6 capable. 0:ipv6 capable. 1:ipv4 only. -1:Not a valid host (no DNS record?) 64 """ 65 adrinfo = socket.getaddrinfo(host, None) You will not catch the exception here if your host does not exist. You can do something like this:
def isHostIPV6(host): """ Test if the given host is ipv6 capable. 0:ipv6 capable. 1:ipv4 only. -1:Not a valid host (no DNS record?) """ try: # try first IPV6 adrinfo = socket.getaddrinfo(host, None, socket.AF_INET6) return 0 except socket.gaierror: No IPv6 address try: # then try IPv4 adrinfo = socket.getaddrinfo(host, None, socket.AF_INET) return 1 except socket.gaierror: # The host does not exist (no IPv6 nor IPv4) return -1 In [9]: isHostIPV6('srm-lhcb.cern.ch') Out[9]: 1 In [10]: isHostIPV6('srm-eoslhcb.cern.ch') Out[10]: 0 In [11]: isHostIPV6('srm-nonexist.cern.ch') Out[11]: -1
changed this line in version 3 of the diff
Just for the record, and as discussed with @nraja: the topology agent is just supposed to dump the content of the CS in a form readable by non LHCb specific software (SAM tests, etc). It is not meant to perform tests by itself. Dumping information about whether the host is IPv6 or not is borderline. So we can let this one in
mentioned in commit 915d21fd