From f430ed014bf18e36f7f92d85a64b747d48e9283b Mon Sep 17 00:00:00 2001 From: "SIPOS, Peter" Date: Wed, 16 Nov 2016 14:12:40 +0100 Subject: [PATCH] Add reverse domain creation into Record.apply() When a record successefully added to a domain, it will try to create a reverse lookup domain for that record. In this point we aren't create the records yet... --- app/models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/models.py b/app/models.py index 76a9181..8a8c89d 100644 --- a/app/models.py +++ b/app/models.py @@ -1017,6 +1017,14 @@ class Record(object): return {'status': 'error', 'msg': jdata2['error']} else: logging.info('Record was applied successfully.') + for r in new_records: + r_name = r['name'] + '.' + if r['type'] in ['A', 'AAAA']: + r_content = r['content'] + temp = re.search('^(([a-f0-9]\.){4}(?P.+6.arpa)\.?)|(\.(?P.+r.arpa)\.?)', dns.reversename.from_address(r_content).to_text()) + domain_reverse_name = temp.group('ipv6name') if temp.group('ipv6name') != None else temp.group('ipv4name') + d = Domain() + d.create_reverse_domain(domain, domain_reverse_name) return {'status': 'ok', 'msg': 'Record was applied successfully'} except Exception, e: logging.error("Cannot apply record changes to domain %s. DETAIL: %s" % (str(e), domain))