예제 #1
0
    def build_zone(self, zone: 'DNSZone') -> ConfigDict:
        master_ips = []
        for s_name in zone.servers + [zone.dns_master] + zone.dns_slaves:
            server_itf = find_node(self._node, s_name)
            if server_itf is None:
                lg.error("Cannot find the server node {name} of DNS zone"
                         " {zone}. Are you sure that they are connected to "
                         "the current node {current}?".format(
                             name=s_name,
                             zone=zone.name,
                             current=self._node.name))
                continue
            server = server_itf.node
            for itf in realIntfList(server):
                for ip in itf.ips():
                    if ".arpa" not in zone.name:  # Not a Reverse zone
                        zone.soa_record.add_record(
                            ARecord(s_name, ip.ip.compressed))
                    if s_name == zone.dns_master:
                        master_ips.append(ip.ip.compressed)

                for ip6 in itf.ip6s(exclude_lls=True):
                    if ".arpa" not in zone.name:  # Not a Reverse zone
                        zone.soa_record.add_record(
                            AAAARecord(s_name, ip6.ip.compressed))
                    if s_name == zone.dns_master:
                        master_ips.append(ip6.ip.compressed)

        return ConfigDict(name=zone.soa_record.domain_name,
                          soa_record=zone.soa_record,
                          records=zone.soa_record.records,
                          master=self._node.name == zone.dns_master,
                          master_ips=master_ips)
예제 #2
0
 def _fill_rdnss_addresses(self):
     for itf in realIntfList(self._node):
         for rdnss in itf.rdnss_list:
             if rdnss.ips is None:
                 rdnss.ips = []
                 dns = find_node(self._node, rdnss.node).node
                 for dns_itf in realIntfList(dns):
                     for ip in dns_itf.ip6s(exclude_lls=True):
                         rdnss.ips.append(ip.ip.compressed)
예제 #3
0
def test_find_node(start, node, present):
    try:
        net = IPNet(topo=StaticAddressNet())
        net.start()
        i = utils.find_node(net[start], node)
        if present:
            assert i is not None,\
                "Node %s not found from node %s" % (node, start)
            assert i.node.name == node,\
                "Node %s was found while we expected %s" % (i.node.name, node)
        else:
            assert i is None,\
                "Node %s should not be found from node %s" % (node, start)
        net.stop()
    finally:
        cleanup()