コード例 #1
0
def get_fully_qualified_name(ngams_server):
    """
    Get fully qualified server name for the input NGAS server object
    :param ngams_server: ngamsServer, Reference to NG/AMS server class object
    :return: string, fully qualified host name (host name + domain + port)
    """
    # Get hots_id, domain and port using ngamsLib functions
    host_name = getHostName()
    domain = ngamsLib.getDomain()
    # Concatenate all elements to construct full qualified name
    # Notice that host_id may contain port number
    fqdn = host_name + "." + domain
    return fqdn
コード例 #2
0
ファイル: ngamsCmd_MIRREXEC.py プロジェクト: ICRAR/ngas
def get_fully_qualified_name(ngams_server):
    """
    Get fully qualified server name for the input NGAS server object
    :param ngams_server: ngamsServer, Reference to NG/AMS server class object
    :return: string, full qualified host name (host name + domain + port)
    """

    # Get hots_id, domain and port using ngamsLib functions
    host_id = ngams_server.getHostId()
    simple_hostname = host_id.split('.')[0]
    domain = ngamsLib.getDomain()
    port = str(ngams_server.getCfg().getPortNo())
    # Concatenate all elements to construct full qualified name
    # Notice that host_id may contain port number
    fqdn = (simple_hostname.rsplit(":"))[0] + "." + domain + ":" + port
    return fqdn
コード例 #3
0
def get_full_qualified_name(srvObj):
    """
    Get full qualified server name for the input NGAS server object

    INPUT:
        srvObj  ngamsServer, Reference to NG/AMS server class object

    RETURNS:
        fqdn    string, full qualified host name (host name + domain + port)
    """

    # Get hots_id, domain and port using ngamsLib functions
    hostName = getHostName()
    domain = ngamsLib.getDomain()
    # Concatenate all elements to construct full qualified name
    # Notice that host_id may contain port number
    fqdn = hostName + "." + domain

    # Return full qualified server name
    return fqdn
コード例 #4
0
def get_fqdn(location, host_id, domain):
    """
    Attempts to construct a fully qualified domain name (FQDN)
    from the NGAS node address attributes

    Parameters:

    location:       File location (local, cluster, remote, etc)

    host_id:        NGAS server host ID

    domain:         NGAS server domain name

    Returns:

    FQDN:           Fully Qualified Domain NAME (so far as possible)

    """
    if not host_id:
        return None

    # TODO: We should really check if the host_id is an IP address

    # Does the host_id contain the port?
    hostname = host_id.rsplit(":")[0]
    domainname = domain

    # Does the host address contain a domain?
    # TODO: This is a crude way of checking by assuming that the domain always follows a '.'
    if "." in hostname:
        return hostname

    if not domainname and location in (NGAMS_HOST_LOCAL, NGAMS_HOST_CLUSTER,
                                       NGAMS_HOST_DOMAIN):
        domainname = ngamsLib.getDomain()

    if hostname and domainname:
        hostname = "{}.{}".format(hostname, domainname)

    return hostname