hooks/ceph_radosgw_context.py
def ensure_host_resolvable_v6(hostname):
    """Ensure that we can resolve our hostname to an IPv6 address by adding it
    to /etc/hosts if it is not already resolvable.
    """
    try:
        socket.getaddrinfo(hostname, None, socket.AF_INET6)
    except socket.gaierror:
        log("Host '%s' is not ipv6 resolvable - adding to /etc/hosts" %
            hostname, level=DEBUG)
    else:
        log("Host '%s' appears to be ipv6 resolvable" % (hostname),
            level=DEBUG)
        return

    # This must be the backend address used by haproxy
    host_addr = get_ipv6_addr(exc_list=[config('vip')])[0]
    dtmp = tempfile.mkdtemp()
    try:
        tmp_hosts = os.path.join(dtmp, 'hosts')
        shutil.copy('/etc/hosts', tmp_hosts)
        with open(tmp_hosts, 'a+') as fd:
            lines = fd.readlines()
            for line in lines:
                key = r"^%s\s+" % (host_addr)
                if re.search(key, line):
                    break
            else:
                fd.write("%s\t%s\n" % (host_addr, hostname))

            os.rename(tmp_hosts, '/etc/hosts')
    finally:
        shutil.rmtree(dtmp)
Ensure that we can resolve our hostname to an IPv6 address by adding it
    to /etc/hosts if it is not already resolvable.
    
Ensure that we can resolve our hostname to an IPv6 address by adding it
to /etc/hosts if it is not already resolvable.
Ensure that we can resolve our hostname to an IPv6 address by adding it to / etc / hosts if it is not already resolvable .
def ensure_host_resolvable_v6(hostname):
    try:
        socket.getaddrinfo(hostname, None, socket.AF_INET6)
    except socket.gaierror:
        log("Host '%s' is not ipv6 resolvable - adding to /etc/hosts" %
            hostname, level=DEBUG)
    else:
        log("Host '%s' appears to be ipv6 resolvable" % (hostname),
            level=DEBUG)
        return
    host_addr = get_ipv6_addr(exc_list=[config('vip')])[0]
    dtmp = tempfile.mkdtemp()
    try:
        tmp_hosts = os.path.join(dtmp, 'hosts')
        shutil.copy('/etc/hosts', tmp_hosts)
        with open(tmp_hosts, 'a+') as fd:
            lines = fd.readlines()
            for line in lines:
                key = r"^%s\s+" % (host_addr)
                if re.search(key, line):
                    break
            else:
                fd.write("%s\t%s\n" % (host_addr, hostname))
            os.rename(tmp_hosts, '/etc/hosts')
    finally:
        shutil.rmtree(dtmp)
def ensure_host_resolvable_v6 ( hostname ) : try : socket . getaddrinfo ( hostname , None , socket . AF_INET6 ) except socket . gaierror : log ( "Host '%s' is not ipv6 resolvable - adding to /etc/hosts" % hostname , level = DEBUG ) else : log ( "Host '%s' appears to be ipv6 resolvable" % ( hostname ) , level = DEBUG ) return host_addr = get_ipv6_addr ( exc_list = [ config ( 'vip' ) ] ) [ 0 ] dtmp = tempfile . mkdtemp ( ) try : tmp_hosts = os . path . join ( dtmp , 'hosts' ) shutil . copy ( '/etc/hosts' , tmp_hosts ) with open ( tmp_hosts , 'a+' ) as fd : lines = fd . readlines ( ) for line in lines : key = r"^%s\s+" % ( host_addr ) if re . search ( key , line ) : break else : fd . write ( "%s\t%s\n" % ( host_addr , hostname ) ) os . rename ( tmp_hosts , '/etc/hosts' ) finally : shutil . rmtree ( dtmp )
Ensure that we can resolve our hostname to an IPv6 address by adding it
to /etc/hosts if it is not already resolvable.
Ensure that we can resolve our hostname to an IPv6 address by adding it to / etc / hosts if it is not already resolvable .
"""Ensure that we can resolve our hostname to an IPv6 address by adding it
    to /etc/hosts if it is not already resolvable.
    """ # This must be the backend address used by haproxy
hostname