DNS Locations: do not generate location records for unused locations

Location records for locations without assigned servers are useless and
we should not generate them.

https://fedorahosted.org/freeipa/ticket/2008

Reviewed-By: Petr Spacek <pspacek@redhat.com>
This commit is contained in:
Martin Basti 2016-06-16 15:24:08 +02:00
parent b2931210eb
commit bbf8227e3f

View File

@ -59,6 +59,7 @@ class IPASystemRecords(object):
self.api_instance = api_instance
self.domain_abs = DNSName(self.api_instance.env.domain).make_absolute()
self.servers_data = {}
self.used_locations = set()
self.__init_data()
def reload_data(self):
@ -79,6 +80,7 @@ class IPASystemRecords(object):
def __init_data(self):
self.servers_data = {}
self.used_locations = set()
servers_result = self.api_instance.Command.server_find(
pkey_only=True)['result']
@ -90,6 +92,8 @@ class IPASystemRecords(object):
'location': location,
'roles': roles,
}
if location:
self.used_locations.add(location)
def __add_srv_records(
self, zone_obj, hostname, rname_port_map,
@ -306,13 +310,12 @@ class IPASystemRecords(object):
pkey_only=True)['result']
servers = [s['cn'][0] for s in servers_result]
locations_result = self.api_instance.Command.location_find()['result']
locations = [l['idnsname'][0] for l in locations_result]
# generate only records for used location, records for unassigned
# locations are useless
for server in servers:
self._get_location_dns_records_for_server(
zone_obj, server,
locations, roles=roles,
self.used_locations, roles=roles,
include_master_role=include_master_role)
return zone_obj