Fix PoweDNSBackend record type and error handling
parent
47045e3e9a
commit
d8b5bc479b
|
@ -2,6 +2,10 @@ import requests
|
|||
import json
|
||||
|
||||
|
||||
class BackendException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class Backend(object):
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
@ -55,15 +59,19 @@ class PowerDNSBackend(Backend):
|
|||
self.config.get('PDNS_URL', 'http://127.0.0.1:8081'),
|
||||
self.config['PDNS_ZONE'],
|
||||
)
|
||||
return requests.patch(api_url, data=json.dumps(reqdata), headers={
|
||||
|
||||
resp = requests.patch(api_url, data=json.dumps(reqdata), headers={
|
||||
'X-API-Key': self.config['PDNS_TOKEN']
|
||||
}).json()
|
||||
|
||||
if 'error' in resp:
|
||||
raise BackendException(resp['error'])
|
||||
|
||||
def add(self, name, value, type_):
|
||||
self.do_patch({
|
||||
"rrsets": [{
|
||||
"name": name + ".",
|
||||
"type": "A",
|
||||
"type": type_,
|
||||
"ttl": 86400,
|
||||
"changetype": "REPLACE",
|
||||
"records": [{
|
||||
|
|
Loading…
Reference in New Issue