Skip to content
Snippets Groups Projects
Verified Commit c1696d7c authored by Michael Filz's avatar Michael Filz
Browse files

fix deleting just updated record

parent e8f3dd7b
No related branches found
No related tags found
No related merge requests found
...@@ -305,7 +305,7 @@ class SOLID(object): ...@@ -305,7 +305,7 @@ class SOLID(object):
return {'fqdn': fqdn, 'type': record_type, 'entries': data} return {'fqdn': fqdn, 'type': record_type, 'entries': data}
def add(self, fqdn: str, record_type: str, data: tuple, ttl: int, defer_update: bool = False) -> None: def add(self, fqdn: str, record_type: str, data: tuple, ttl: int, defer_update: bool = False) -> str:
""" """
Add a DNS record Add a DNS record
...@@ -313,6 +313,8 @@ class SOLID(object): ...@@ -313,6 +313,8 @@ class SOLID(object):
record_type: DNS record type, e.g. A record_type: DNS record type, e.g. A
data: record entry, e.g. the IPv4 address for an A record data: record entry, e.g. the IPv4 address for an A record
ttl: record time to live ttl: record time to live
return value: oid of the new record
""" """
logging.debug(f'Adding { record_type } record for { fqdn }') logging.debug(f'Adding { record_type } record for { fqdn }')
servers = self.__servers_for_fqdn(fqdn) servers = self.__servers_for_fqdn(fqdn)
...@@ -333,6 +335,7 @@ class SOLID(object): ...@@ -333,6 +335,7 @@ class SOLID(object):
raise SOLIDError(f'Failed to add or update { record_type } record for { fqdn } on { s }: { r["err_msg"] }') raise SOLIDError(f'Failed to add or update { record_type } record for { fqdn } on { s }: { r["err_msg"] }')
if not defer_update: if not defer_update:
self.records = self.__get_records() self.records = self.__get_records()
return r['ret_oid']
def delete(self, fqdn: str, record_type: str) -> int: def delete(self, fqdn: str, record_type: str) -> int:
...@@ -379,7 +382,7 @@ class SOLID(object): ...@@ -379,7 +382,7 @@ class SOLID(object):
logging.debug(f'WANT server={s}, fqdn={fqdn}, type={record_type}, data={", ".join(self.__to_tuple(p["data"]))}, ttl={p["ttl"]}') logging.debug(f'WANT server={s}, fqdn={fqdn}, type={record_type}, data={", ".join(self.__to_tuple(p["data"]))}, ttl={p["ttl"]}')
match = [ r for r in self.records if r['dns_name'] == s and r['rr_type'] == record_type and r['rr_full_name_utf'] == fqdn and r['rr_all_value'] == ', '.join(self.__to_tuple(p["data"])) and r['ttl'] == str(p['ttl']) ] match = [ r for r in self.records if r['dns_name'] == s and r['rr_type'] == record_type and r['rr_full_name_utf'] == fqdn and r['rr_all_value'] == ', '.join(self.__to_tuple(p["data"])) and r['ttl'] == str(p['ttl']) ]
if not match: if not match:
self.add(fqdn, record_type, p['data'], p['ttl'], defer_update = True) found.append(self.add(fqdn, record_type, p['data'], p['ttl'], defer_update = True))
changed = True changed = True
elif len(match) == 1: elif len(match) == 1:
logging.debug(f'FOUND server={s}, fqdn={fqdn}, type={record_type}, data={", ".join(self.__to_tuple(p["data"]))}, ttl={p["ttl"]}') logging.debug(f'FOUND server={s}, fqdn={fqdn}, type={record_type}, data={", ".join(self.__to_tuple(p["data"]))}, ttl={p["ttl"]}')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment