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 2020/11/01 20:54:39 UTC
[libcloud] branch trunk updated (a8aecff -> d9c1701)
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 a8aecff Add changelog entry.
new a9c3c64 Fix error when creating SSHFP DNS records with cloudflare
new f93ac86 Merge branch 'bug/1512' of https://github.com/insertjokehere/libcloud into insertjokehere-bug/1512
new 54276d3 To be on the safe side, only include data attribute on record create and update if it's not empty.
new 98b8da3 Add changelog entry.
new ec9bd4f Clarify that no de-normalization is needed for SSHFP records on response.
new d9c1701 Add additional test case and assertions.
The 6 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 | 4 ++
libcloud/dns/drivers/cloudflare.py | 45 ++++++++++++++++----
.../{records_POST.json => records_POST_sshfp.json} | 8 ++--
libcloud/test/dns/test_cloudflare.py | 49 ++++++++++++++++++++--
4 files changed, 91 insertions(+), 15 deletions(-)
copy libcloud/test/dns/fixtures/cloudflare/{records_POST.json => records_POST_sshfp.json} (79%)
[libcloud] 04/06: Add changelog entry.
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 98b8da3a75ddbfd001e7cd6d909676baf82c062f
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:39:24 2020 +0100
Add changelog entry.
---
CHANGES.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGES.rst b/CHANGES.rst
index e751719..662261d 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -81,6 +81,10 @@ DNS
(GITHUB-1500)
[Tomaz Muraus - @Kami]
+- [CloudFlare DNS] Add support for creating ``SSHFP`` records.
+ (GITHUB-1512, GITHUB-1513)
+ [Will Hughes - @insertjokehere]
+
Changes in Apache Libcloud 3.2.0
--------------------------------
[libcloud] 03/06: To be on the safe side,
only include data attribute on record create and update if it's not
empty.
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 54276d3857a4e64c11bacd52bc4f48acdecc35b0
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:35:44 2020 +0100
To be on the safe side, only include data attribute on record create
and update if it's not empty.
This way data will only be provided for SSHFP records.
---
libcloud/dns/drivers/cloudflare.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/libcloud/dns/drivers/cloudflare.py b/libcloud/dns/drivers/cloudflare.py
index 62dcbf4..31de7e7 100644
--- a/libcloud/dns/drivers/cloudflare.py
+++ b/libcloud/dns/drivers/cloudflare.py
@@ -329,10 +329,12 @@ class CloudFlareDNSDriver(DNSDriver):
body = {
'type': type,
'name': name,
- 'content': content,
- 'data': data
+ 'content': content
}
+ if data:
+ body['data'] = data
+
merge_valid_keys(body, RECORD_CREATE_ATTRIBUTES, extra)
self.connection.set_context({'zone_id': zone.id})
@@ -362,10 +364,12 @@ class CloudFlareDNSDriver(DNSDriver):
'type': record.type if type is None else type,
'name': record.name if name is None else name,
'content': content,
- 'data': data,
'extra': record.extra or {},
}
+ if data:
+ body['data'] = data
+
merge_valid_keys(body['extra'], RECORD_UPDATE_ATTRIBUTES, extra)
self.connection.set_context({'record_id': record.id})
[libcloud] 05/06: Clarify that no de-normalization is needed for
SSHFP records on response.
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 ec9bd4f02bee197cec1208af0e9e6d4223ff8f27
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:49:28 2020 +0100
Clarify that no de-normalization is needed for SSHFP records on
response.
---
libcloud/dns/drivers/cloudflare.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libcloud/dns/drivers/cloudflare.py b/libcloud/dns/drivers/cloudflare.py
index 31de7e7..607135b 100644
--- a/libcloud/dns/drivers/cloudflare.py
+++ b/libcloud/dns/drivers/cloudflare.py
@@ -451,6 +451,12 @@ class CloudFlareDNSDriver(DNSDriver):
"""
Normalize record data for "special" records such as CAA and SSHFP
so it can be used with the CloudFlare API.
+
+ Keep ind mind that value for SSHFP record type onluy needs to be
+ normalized for the create / update operations.
+
+ On list operation (aka response), actual value is returned
+ normally in the "content" attribute.
"""
cf_data = {}
if not data:
[libcloud] 06/06: Add additional test case and assertions.
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 d9c1701b856b93d875599523158b3d2273f6f762
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:52:42 2020 +0100
Add additional test case and assertions.
---
.../fixtures/cloudflare/records_POST_sshfp.json | 24 +++++++++++++++++
libcloud/test/dns/test_cloudflare.py | 30 ++++++++++++++++++++++
2 files changed, 54 insertions(+)
diff --git a/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json b/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json
new file mode 100644
index 0000000..a1eaaf6
--- /dev/null
+++ b/libcloud/test/dns/fixtures/cloudflare/records_POST_sshfp.json
@@ -0,0 +1,24 @@
+{
+ "result": {
+ "id": "200",
+ "type": "SSHFP",
+ "name": "test_sshfp.example.com",
+ "content": "2 1 ABCDEF12345",
+ "proxiable": true,
+ "proxied": true,
+ "ttl": 1,
+ "locked": false,
+ "zone_id": "1234",
+ "zone_name": "example.com",
+ "modified_on": "2018-12-22T21:28:00.801892Z",
+ "created_on": "2018-12-22T21:28:00.801892Z",
+ "meta": {
+ "auto_added": false,
+ "managed_by_apps": false,
+ "managed_by_argo_tunnel": false
+ }
+ },
+ "success": true,
+ "errors": [],
+ "messages": []
+}
diff --git a/libcloud/test/dns/test_cloudflare.py b/libcloud/test/dns/test_cloudflare.py
index e851be8..125edf2 100644
--- a/libcloud/test/dns/test_cloudflare.py
+++ b/libcloud/test/dns/test_cloudflare.py
@@ -137,6 +137,18 @@ class CloudFlareDNSDriverTestCase(unittest.TestCase):
self.assertEqual(record.type, 'A')
self.assertEqual(record.data, '127.0.0.3')
+ def test_create_record_SSHFP_record_type(self):
+ zone = self.driver.list_zones()[0]
+
+ CloudFlareMockHttp.type = 'sshfp_record_type'
+ record = self.driver.create_record(name='test_sshfp', zone=zone,
+ type=RecordType.SSHFP,
+ data='2 1 ABCDEF12345')
+ self.assertEqual(record.id, '200')
+ self.assertEqual(record.name, 'test_sshfp')
+ self.assertEqual(record.type, 'SSHFP')
+ self.assertEqual(record.data, '2 1 ABCDEF12345')
+
def test_create_record_CAA_record_type(self):
zone = self.driver.list_zones()[0]
@@ -353,6 +365,24 @@ class CloudFlareMockHttp(MockHttp, unittest.TestCase):
return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+ def _client_v4_zones_1234_dns_records_sshfp_record_type(self, method, url, body, headers):
+ if method not in ['POST']:
+ raise AssertionError('Unsupported method: %s' % (method))
+
+ url = urlparse.urlparse(url)
+ # Verify record data has been correctly normalized
+ body = json.loads(body)
+ expected_data = {
+ "algorithm": "2",
+ "type": "1",
+ "fingerprint": "ABCDEF12345"
+ }
+ self.assertEqual(body['data'], expected_data)
+
+ body = self.fixtures.load('records_{}_sshfp.json'.format(method))
+
+ return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
def _client_v4_zones_1234_dns_records_error_chain_error(self, method, url, body, headers):
if method not in ['POST']:
raise AssertionError('Unsupported method: %s' % (method))
[libcloud] 01/06: Fix error when creating SSHFP DNS records with
cloudflare
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 a9c3c64f553ca9f9aef5b76176eb91ab9807a80e
Author: William Hughes <wi...@willhughes.name>
AuthorDate: Mon Oct 26 17:12:47 2020 +1300
Fix error when creating SSHFP DNS records with cloudflare
Fixes #1512
---
libcloud/dns/drivers/cloudflare.py | 35 +++++++++++++++++++++++++++--------
libcloud/test/dns/test_cloudflare.py | 19 ++++++++++++++++---
2 files changed, 43 insertions(+), 11 deletions(-)
diff --git a/libcloud/dns/drivers/cloudflare.py b/libcloud/dns/drivers/cloudflare.py
index 5715b79..62dcbf4 100644
--- a/libcloud/dns/drivers/cloudflare.py
+++ b/libcloud/dns/drivers/cloudflare.py
@@ -317,14 +317,20 @@ class CloudFlareDNSDriver(DNSDriver):
or iodef.
For example: 0 issue test.caa.com
+
+ NOTE: For SSHFP RecordType, data need to be in the format:
+ <algorithm> <type> <fingerprint>
"""
url = '{}/zones/{}/dns_records'.format(API_BASE, zone.id)
- data = self._normalize_record_data_for_api(type=type, data=data,)
+ content, data = self._normalize_record_data_for_api(
+ type=type, data=data
+ )
body = {
'type': type,
'name': name,
- 'content': data,
+ 'content': content,
+ 'data': data
}
merge_valid_keys(body, RECORD_CREATE_ATTRIBUTES, extra)
@@ -349,11 +355,14 @@ class CloudFlareDNSDriver(DNSDriver):
url = '{}/zones/{}/dns_records/{}'.format(API_BASE, record.zone.id,
record.id)
- data = self._normalize_record_data_for_api(type=type, data=data,)
+ content, data = self._normalize_record_data_for_api(
+ type=type, data=data
+ )
body = {
'type': record.type if type is None else type,
'name': record.name if name is None else name,
- 'content': record.data if data is None else data,
+ 'content': content,
+ 'data': data,
'extra': record.extra or {},
}
@@ -436,18 +445,28 @@ class CloudFlareDNSDriver(DNSDriver):
def _normalize_record_data_for_api(self, type, data):
"""
- Normalize record data for "special" records such as CAA so it can be
- used with the CloudFlare API.
+ Normalize record data for "special" records such as CAA and SSHFP
+ so it can be used with the CloudFlare API.
"""
+ cf_data = {}
if not data:
- return data
+ return data, cf_data
if type == RecordType.CAA:
# Replace whitespace with \t character which CloudFlare API
# expects
data = data.replace(' ', '\t')
- return data
+ elif type == RecordType.SSHFP:
+ _fp = data.split(" ")
+ cf_data = {
+ "algorithm": _fp[0],
+ "type": _fp[1],
+ "fingerprint": _fp[2]
+ }
+ data = None
+
+ return data, cf_data
def _normalize_record_data_from_api(self, type, data):
"""
diff --git a/libcloud/test/dns/test_cloudflare.py b/libcloud/test/dns/test_cloudflare.py
index 93ffcae..e851be8 100644
--- a/libcloud/test/dns/test_cloudflare.py
+++ b/libcloud/test/dns/test_cloudflare.py
@@ -261,9 +261,22 @@ class CloudFlareDNSDriverTestCase(unittest.TestCase):
self.assertEqual(zone, updated_zone)
- def test_normalize_record_data_for_api(self):
- result = self.driver._normalize_record_data_for_api(RecordType.CAA, '0 issue foo.bar')
- self.assertEqual(result, '0\tissue\tfoo.bar')
+ def test_caa_normalize_record_data_for_api(self):
+ content, data = self.driver._normalize_record_data_for_api(RecordType.CAA, '0 issue foo.bar')
+ self.assertEqual(content, '0\tissue\tfoo.bar')
+ self.assertEqual(data, {})
+
+ def test_sshfp_normalize_record_data_for_api(self):
+ content, data = self.driver._normalize_record_data_for_api(RecordType.SSHFP, '2 1 ABCDEF12345')
+ self.assertIsNone(content)
+ self.assertEqual(
+ data,
+ {
+ "algorithm": "2",
+ "type": "1",
+ "fingerprint": "ABCDEF12345"
+ }
+ )
def test_normalize_record_data_from_apu(self):
result = self.driver._normalize_record_data_from_api(RecordType.CAA, '0\tissue\tfoo.bar')
[libcloud] 02/06: Merge branch 'bug/1512' of
https://github.com/insertjokehere/libcloud into insertjokehere-bug/1512
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 f93ac86ff1d61706b22580f134b4e4942f10382c
Merge: a8aecff a9c3c64
Author: Tomaz Muraus <to...@tomaz.me>
AuthorDate: Sun Nov 1 21:35:00 2020 +0100
Merge branch 'bug/1512' of https://github.com/insertjokehere/libcloud into insertjokehere-bug/1512
libcloud/dns/drivers/cloudflare.py | 35 +++++++++++++++++++++++++++--------
libcloud/test/dns/test_cloudflare.py | 19 ++++++++++++++++---
2 files changed, 43 insertions(+), 11 deletions(-)