summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPiotr Dobrowolski <admin@tastycode.pl>2017-04-07 00:41:37 +0200
committerPiotr Dobrowolski <admin@tastycode.pl>2017-04-07 00:41:37 +0200
commitd8b5bc479b3a69a595c57041e3237a8c7af7d9c2 (patch)
tree183544d4c4a27d34ec61b22bb26bd92efcbccd4d
parent47045e3e9a40dd39448bfd2262368351f49c5604 (diff)
downloadlocal-letsencrypt-d8b5bc479b3a69a595c57041e3237a8c7af7d9c2.tar.gz
local-letsencrypt-d8b5bc479b3a69a595c57041e3237a8c7af7d9c2.tar.bz2
local-letsencrypt-d8b5bc479b3a69a595c57041e3237a8c7af7d9c2.zip
Fix PoweDNSBackend record type and error handling
-rw-r--r--server/backends.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/server/backends.py b/server/backends.py
index 4546807..8b5a5b4 100644
--- a/server/backends.py
+++ b/server/backends.py
@@ -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": [{