You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2019/08/24 18:48:47 UTC
[libcloud] branch trunk updated (18a510f -> f3186c4)
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git.
from 18a510f Merge pull request #1332 from CatalystCode/detect-broken-yum-python-requests
add 9cab468 powerdns driver adapted to work with pdns 3 and 4, api versione experimental and v1
add 4ac003b [POWERDNS] - deleted extra parameters in create and update record and used already present extra array
new c7cf97e Merge branch 'biggosh/pdns_3_4' of https://github.com/biggosh/libcloud into biggosh-biggosh/pdns_3_4
new 6a78a08 Fix lint.
new 87fb895 More lint and style cleanup.
new f3186c4 Add changelog entry for #1328.
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
CHANGES.rst | 5 +-
libcloud/dns/drivers/powerdns.py | 143 +++++++++++++++++++++++++++++----------
2 files changed, 113 insertions(+), 35 deletions(-)
[libcloud] 01/04: Merge branch 'biggosh/pdns_3_4' of
https://github.com/biggosh/libcloud into biggosh-biggosh/pdns_3_4
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit c7cf97e87f45b0b187235bebc73a87c99e237348
Merge: 18a510f 4ac003b
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Aug 24 20:33:46 2019 +0200
Merge branch 'biggosh/pdns_3_4' of https://github.com/biggosh/libcloud into biggosh-biggosh/pdns_3_4
libcloud/dns/drivers/powerdns.py | 126 +++++++++++++++++++++++++++++----------
1 file changed, 96 insertions(+), 30 deletions(-)
[libcloud] 04/04: Add changelog entry for #1328.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit f3186c43d0341a17502ec485a27b0bc25f64d9da
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Aug 24 20:48:31 2019 +0200
Add changelog entry for #1328.
---
CHANGES.rst | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/CHANGES.rst b/CHANGES.rst
index 9c07567..9c02355 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -235,7 +235,10 @@ DNS
[Clemens Wolff - @c-w]
- [Gandi LiveDNS] Add new driver for Gandi LiveDNS service. (GITHUB-1323)
- [Ryan Lee - @zepheiryan
+ [Ryan Lee - @zepheiryan]
+
+- [PowerDNS] Update driver so it works with API v3 and v4. #1328
+ [@biggosh]
Changes in Apache Libcloud 2.5.0
--------------------------------
[libcloud] 02/04: Fix lint.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 6a78a085d917a00826c9393fc61a8142343fbdb9
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Aug 24 20:34:14 2019 +0200
Fix lint.
---
libcloud/dns/drivers/powerdns.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/libcloud/dns/drivers/powerdns.py b/libcloud/dns/drivers/powerdns.py
index 23557be..a505fa7 100644
--- a/libcloud/dns/drivers/powerdns.py
+++ b/libcloud/dns/drivers/powerdns.py
@@ -180,7 +180,7 @@ class PowerDNSDriver(DNSDriver):
zone.id)
if extra is None or extra.get('ttl', None) is None:
raise ValueError('PowerDNS requires a ttl value for every record')
-
+
if self._pdns_version() == 3:
record = {
'content': data,
@@ -195,7 +195,7 @@ class PowerDNSDriver(DNSDriver):
'records': [record]
}]
}
-
+
if self._pdns_version() == 4:
disabled = False
if 'disabled' in extra:
@@ -438,12 +438,11 @@ class PowerDNSDriver(DNSDriver):
'records': [updated_record]
}]
}
-
+
if self._pdns_version() == 4:
disabled = False
if "disabled" in extra:
disabled = extra['disabled']
- comment = None
updated_record = {
'content': data,
'disabled': disabled,
@@ -461,7 +460,7 @@ class PowerDNSDriver(DNSDriver):
if 'comment' in extra:
payload["rrsets"][0]["comments"] = extra['comment']
-
+
try:
self.connection.request(action=action, data=json.dumps(payload),
method='PATCH')
@@ -491,7 +490,7 @@ class PowerDNSDriver(DNSDriver):
zones.append(self._to_zone(item))
return zones
- def _to_record(self, item, zone, record = None):
+ def _to_record(self, item, zone, record=None):
if record is None:
data = item['content']
else:
@@ -510,8 +509,8 @@ class PowerDNSDriver(DNSDriver):
for record in item['records']:
records.append(self._to_record(item, zone, record))
return records
-
+
def _pdns_version(self):
if self.api_root == '': return 3
if self.api_root == '/api/v1': return 4
- raise ValueError('PowerDNS version has not been declared')
\ No newline at end of file
+ raise ValueError('PowerDNS version has not been declared')
[libcloud] 03/04: More lint and style cleanup.
Posted by to...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tomaz pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit 87fb895ca400b0cd9cbffe08f7ca899ac1a6b489
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sat Aug 24 20:42:02 2019 +0200
More lint and style cleanup.
---
libcloud/dns/drivers/powerdns.py | 84 ++++++++++++++++++++++------------------
1 file changed, 47 insertions(+), 37 deletions(-)
diff --git a/libcloud/dns/drivers/powerdns.py b/libcloud/dns/drivers/powerdns.py
index a505fa7..5e96d0e 100644
--- a/libcloud/dns/drivers/powerdns.py
+++ b/libcloud/dns/drivers/powerdns.py
@@ -176,6 +176,8 @@ class PowerDNSDriver(DNSDriver):
:rtype: :class:`Record`
"""
+ extra = extra or {}
+
action = '%s/servers/%s/zones/%s' % (self.api_root, self.ex_server,
zone.id)
if extra is None or extra.get('ttl', None) is None:
@@ -189,35 +191,36 @@ class PowerDNSDriver(DNSDriver):
'ttl': extra['ttl'],
'type': type,
}
- payload = {'rrsets': [{'name': name,
- 'type': type,
- 'changetype': 'REPLACE',
- 'records': [record]
- }]
- }
-
- if self._pdns_version() == 4:
- disabled = False
- if 'disabled' in extra:
- disabled = extra['disabled']
+ payload = {
+ 'rrsets': [
+ {
+ 'name': name,
+ 'type': type,
+ 'changetype': 'REPLACE',
+ 'records': [record]
+ }
+ ]
+ }
+ elif self._pdns_version() == 4:
record = {
'content': data,
- 'disabled': disabled,
+ 'disabled': extra.get('disabled', False),
'set-ptr': False,
}
payload = {
- 'rrsets': [{
- 'name': name,
- 'type': type,
- 'changetype': 'REPLACE',
- 'ttl': extra['ttl'],
- 'records': [record],
- }]
+ 'rrsets': [
+ {
+ 'name': name,
+ 'type': type,
+ 'changetype': 'REPLACE',
+ 'ttl': extra['ttl'],
+ 'records': [record],
+ }
+ ]
}
if 'comment' in extra:
- payload["rrsets"][0]["comments"] = extra['comment']
-
+ payload['rrsets'][0]['comments'] = extra['comment']
try:
self.connection.request(action=action, data=json.dumps(payload),
@@ -419,7 +422,7 @@ class PowerDNSDriver(DNSDriver):
record.zone.id)
if extra is None or extra.get('ttl', None) is None:
raise ValueError('PowerDNS requires a ttl value for every record')
-
+
if self._pdns_version() == 3:
updated_record = {
'content': data,
@@ -428,18 +431,22 @@ class PowerDNSDriver(DNSDriver):
'ttl': extra['ttl'],
'type': type,
}
- payload = {'rrsets': [{'name': record.name,
- 'type': record.type,
- 'changetype': 'DELETE',
- },
- {'name': name,
- 'type': type,
- 'changetype': 'REPLACE',
- 'records': [updated_record]
- }]
- }
-
- if self._pdns_version() == 4:
+ payload = {
+ 'rrsets': [
+ {
+ 'name': record.name,
+ 'type': record.type,
+ 'changetype': 'DELETE',
+ },
+ {
+ 'name': name,
+ 'type': type,
+ 'changetype': 'REPLACE',
+ 'records': [updated_record]
+ }
+ ]
+ }
+ elif self._pdns_version() == 4:
disabled = False
if "disabled" in extra:
disabled = extra['disabled']
@@ -504,13 +511,16 @@ class PowerDNSDriver(DNSDriver):
if self._pdns_version() == 3:
for item in items.object['records']:
records.append(self._to_record(item, zone))
- if self._pdns_version() == 4:
+ elif self._pdns_version() == 4:
for item in items.object['rrsets']:
for record in item['records']:
records.append(self._to_record(item, zone, record))
return records
def _pdns_version(self):
- if self.api_root == '': return 3
- if self.api_root == '/api/v1': return 4
+ if self.api_root == '':
+ return 3
+ elif self.api_root == '/api/v1':
+ return 4
+
raise ValueError('PowerDNS version has not been declared')