diff options
author | Martin Basti <mbasti@redhat.com> | 2016-06-16 16:46:29 +0200 |
---|---|---|
committer | Martin Basti <mbasti@redhat.com> | 2016-06-17 18:05:03 +0200 |
commit | 3c50e42036427d7c5e36828f24bd3c180e18a677 (patch) | |
tree | 36c379a5bce1a75ed7870b594968a32147c2ecee /ipaserver/dns_data_management.py | |
parent | bbf8227e3fd678d4bd6659a12055ba3dbe1c8230 (diff) | |
download | freeipa-3c50e42036427d7c5e36828f24bd3c180e18a677.tar.gz freeipa-3c50e42036427d7c5e36828f24bd3c180e18a677.tar.xz freeipa-3c50e42036427d7c5e36828f24bd3c180e18a677.zip |
DNS Locations: location-del: remove location record
Remove unused location records
https://fedorahosted.org/freeipa/ticket/2008
Reviewed-By: Petr Spacek <pspacek@redhat.com>
Diffstat (limited to 'ipaserver/dns_data_management.py')
-rw-r--r-- | ipaserver/dns_data_management.py | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/ipaserver/dns_data_management.py b/ipaserver/dns_data_management.py index d01e1137c..b6ae27ad3 100644 --- a/ipaserver/dns_data_management.py +++ b/ipaserver/dns_data_management.py @@ -78,6 +78,9 @@ class IPASystemRecords(object): return weight, location, roles + def __get_location_suffix(self, location): + return location + DNSName('_locations') + self.domain_abs + def __init_data(self): self.servers_data = {} self.used_locations = set() @@ -104,9 +107,7 @@ class IPASystemRecords(object): assert isinstance(weight, int) if location: - suffix = ( - location + DNSName('_locations') + self.domain_abs - ) + suffix = self.__get_location_suffix(location) else: suffix = self.domain_abs @@ -388,6 +389,40 @@ class IPASystemRecords(object): self.update_locations_records() ) + def remove_location_records(self, location): + """ + Remove all location records + :param location: DNSName object + :return: list of successfuly removed record names, list of record + names that cannot be removed and returned exception in tuples + [rname1, ...], [(rname2, exc), ...] + """ + success = [] + failed = [] + + location = DNSName(location) + loc_records = [] + for records in ( + IPA_DEFAULT_MASTER_SRV_REC, + IPA_DEFAULT_ADTRUST_SRV_REC, + ): + for name, _port in records: + loc_records.append( + name + self.__get_location_suffix(location)) + + for rname in loc_records: + try: + self.api_instance.Command.dnsrecord_del( + self.domain_abs, rname, del_all=True) + except errors.NotFound: + pass + except errors.PublicError as e: + failed.append((rname, e)) + else: + success.append(rname) + return success, failed + + @classmethod def records_list_from_node(cls, name, node): records = [] |