mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-08 22:50:26 +00:00
Use correct TTL in updates.
This commit is contained in:
parent
2cf88739b9
commit
0d1aa7971b
@ -888,14 +888,14 @@ class Record(object):
|
||||
|
||||
# Adjustment to add multiple records which described in https://github.com/ngoduykhanh/PowerDNS-Admin/issues/5#issuecomment-181637576
|
||||
final_records = []
|
||||
if NEW_SCHEMA:
|
||||
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
||||
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"])):
|
||||
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
||||
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"], item["changetype"], item["ttl"])):
|
||||
if NEW_SCHEMA:
|
||||
new_record = {
|
||||
"name": key[0],
|
||||
"type": key[1],
|
||||
"ttl": records[0]['ttl'],
|
||||
"changetype": "REPLACE",
|
||||
"changetype": key[2],
|
||||
"ttl": key[3],
|
||||
"records": []
|
||||
}
|
||||
for item in group:
|
||||
@ -910,13 +910,13 @@ class Record(object):
|
||||
"disabled": temp_disabled
|
||||
})
|
||||
final_records.append(new_record)
|
||||
else:
|
||||
records = sorted(records, key = lambda item: (item["name"], item["type"]))
|
||||
for key, group in itertools.groupby(records, lambda item: (item["name"], item["type"])):
|
||||
|
||||
else:
|
||||
|
||||
final_records.append({
|
||||
"name": key[0],
|
||||
"type": key[1],
|
||||
"changetype": "REPLACE",
|
||||
"changetype": key[2],
|
||||
"records": [
|
||||
{
|
||||
"content": item['records'][0]['content'],
|
||||
@ -935,10 +935,7 @@ class Record(object):
|
||||
headers = {}
|
||||
headers['X-API-Key'] = PDNS_API_KEY
|
||||
jdata1 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_delete)
|
||||
# logging.debug('jdata1: ', jdata1)
|
||||
|
||||
jdata2 = utils.fetch_json(urlparse.urljoin(PDNS_STATS_URL, API_EXTENDED_URL + '/servers/localhost/zones/%s' % domain), headers=headers, method='PATCH', data=postdata_for_new)
|
||||
# logging.debug('jdata2: ', jdata2)
|
||||
|
||||
if 'error' in jdata2.keys():
|
||||
logging.error('Cannot apply record changes.')
|
||||
|
Loading…
Reference in New Issue
Block a user