コード例 #1
0
def _apply_af_awareness(fqdn, address_family):
    """Adds the v4/v6 only annotation to the fqdn.

    Example:
        fqdn:       'ndt.iupui.mlab3.ath01.measurement-lab.org'
        ipv4 only:  'ndt.iupui.mlab3v4.ath01.measurement-lab.org'
        ipv6 only:  'ndt.iupui.mlab3v6.ath01.measurement-lab.org'

    Args:
        fqdn: A tool FQDN with no address family specific annotation.
        address_family: The address family for which to create the FQDN or None
            to create an address family agnostic FQDN.

    Returns:
        A FQDN specific to a particular address family, or the original FQDN
        if an address family is not specified.
    """
    if not address_family:
        fqdn_annotation = ''
    elif address_family == message.ADDRESS_FAMILY_IPv4:
        fqdn_annotation = 'v4'
    elif address_family == message.ADDRESS_FAMILY_IPv6:
        fqdn_annotation = 'v6'
    else:
        logging.error('Unrecognized address family: %s', address_family)
        return fqdn

    fqdn_parts = parse_fqdn.parse(fqdn)
    if not fqdn_parts:
        logging.error('Cannot parse FQDN: %s', fqdn)
        return fqdn
    decorated_machine = fqdn_parts['machine'] + fqdn_annotation

    return fqdn.replace(fqdn_parts['machine'], decorated_machine)
コード例 #2
0
 def testValidV2MachineFqdn(self):
     """A valid v2 machine FQDN."""
     fqdn = 'mlab3-xyz03.measurement-lab.org'
     expected = {
         'experiment': None,
         'org': None,
         'machine': 'mlab3',
         'site': 'xyz03',
         'project': None,
         'domain': 'measurement-lab.org',
     }
     actual = parse_fqdn.parse(fqdn)
     self.assertEqual(expected, actual)
コード例 #3
0
 def testValidV1ExperimentFqdnWithOrg(self):
     """A valid v1 experiment FQDN, with org."""
     fqdn = 'ndt.iupui.mlab4.lga06.measurement-lab.org'
     expected = {
         'experiment': 'ndt',
         'org': 'iupui',
         'machine': 'mlab4',
         'site': 'lga06',
         'project': None,
         'domain': 'measurement-lab.org',
     }
     actual = parse_fqdn.parse(fqdn)
     self.assertEqual(expected, actual)
コード例 #4
0
ファイル: model.py プロジェクト: eumel8/mlab-ns
def get_slice_site_server_ids(fqdn):
    p = parse_fqdn.parse(fqdn)
    if not p:
        return None, None, None

    # If any one of these values is missing, then the whole thing fails.
    if not p['experiment'] or not p['machine'] or not p['site']:
        return None, None, None

    if p['org']:
        experiment = '%s_%s' % (p['org'], p['experiment'])
    else:
        experiment = p['experiment']

    return experiment, p['site'], p['machine']
コード例 #5
0
 def testInvalidV2ExperimentFqdnBadMachineName(self):
     """A invalid v2 experiment FQDN with invalid machine name."""
     fqdn = 'wehe-machine-den05.mlab-oti.measurement-lab.org'
     expected = {}
     actual = parse_fqdn.parse(fqdn)
     self.assertEqual(expected, actual)
コード例 #6
0
 def testInvalidV2ExperimentFqdnTooManyParts(self):
     """A invalid v2 experiment FQDN with too many experiment-org parts"""
     fqdn = 'ndt-iupui-extra-mlab1-den05.mlab-oti.measurement-lab.org'
     expected = {}
     actual = parse_fqdn.parse(fqdn)
     self.assertEqual(expected, actual)
コード例 #7
0
 def testEmptyInput(self):
     """Invalid empty string input."""
     fqdn = ''
     expected = {}
     actual = parse_fqdn.parse(fqdn)
     self.assertEqual(expected, actual)