Modify Zerigo driver to include record TTL in the record 'extra' attribute if a record has a TTL set.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ebcfe186 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ebcfe186 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ebcfe186 Branch: refs/heads/0.13.2 Commit: ebcfe1867f0072ad66573bf874ef68b53747c176 Parents: 602b6a7 Author: Tomaz Muraus <[email protected]> Authored: Fri Sep 6 23:31:45 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Fri Sep 13 15:11:44 2013 +0200 ---------------------------------------------------------------------- CHANGES | 8 ++++++++ libcloud/dns/drivers/zerigo.py | 6 +++++- libcloud/test/dns/fixtures/zerigo/list_records.xml | 13 +++++++++++++ libcloud/test/dns/test_zerigo.py | 5 ++++- 4 files changed, 30 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/ebcfe186/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index ca90c84..249d2d0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,13 @@ -*- coding: utf-8 -*- +Changes with Apache Libcloud 0.13.2 + + *) DNS + + - Modify Zerigo driver to include record TTL in the record 'extra' attribute + if a record has a TTL set. + [Tomaz Muraus] + Changes with Apache Libcloud 0.13.1 *) General http://git-wip-us.apache.org/repos/asf/libcloud/blob/ebcfe186/libcloud/dns/drivers/zerigo.py ---------------------------------------------------------------------- diff --git a/libcloud/dns/drivers/zerigo.py b/libcloud/dns/drivers/zerigo.py index 404b8da..e92c2c3 100644 --- a/libcloud/dns/drivers/zerigo.py +++ b/libcloud/dns/drivers/zerigo.py @@ -423,9 +423,13 @@ class ZerigoDNSDriver(DNSDriver): state = findtext(element=elem, xpath='state') fqdn = findtext(element=elem, xpath='fqdn') priority = findtext(element=elem, xpath='priority') + ttl = findtext(element=elem, xpath='ttl') + + if ttl: + ttl = int(ttl) extra = {'notes': notes, 'state': state, 'fqdn': fqdn, - 'priority': priority} + 'priority': priority, 'ttl': ttl} record = Record(id=id, name=name, type=type, data=data, zone=zone, driver=self, extra=extra) http://git-wip-us.apache.org/repos/asf/libcloud/blob/ebcfe186/libcloud/test/dns/fixtures/zerigo/list_records.xml ---------------------------------------------------------------------- diff --git a/libcloud/test/dns/fixtures/zerigo/list_records.xml b/libcloud/test/dns/fixtures/zerigo/list_records.xml index d2e9530..f0826cf 100644 --- a/libcloud/test/dns/fixtures/zerigo/list_records.xml +++ b/libcloud/test/dns/fixtures/zerigo/list_records.xml @@ -12,4 +12,17 @@ <updated-at type="datetime">2008-12-07T02:51:13Z</updated-at> <zone-id type="integer">12345678</zone-id> </host> + <host> + <created-at type="datetime">2008-12-07T02:51:13Z</created-at> + <data>172.16.16.2</data> + <fqdn>test.example.com</fqdn> + <host-type>A</host-type> + <hostname>test</hostname> + <id type="integer">23456789</id> + <notes nil="true"/> + <priority type="integer" nil="true"/> + <ttl type="integer">3600</ttl> + <updated-at type="datetime">2008-12-07T02:51:13Z</updated-at> + <zone-id type="integer">12345678</zone-id> + </host> </hosts> http://git-wip-us.apache.org/repos/asf/libcloud/blob/ebcfe186/libcloud/test/dns/test_zerigo.py ---------------------------------------------------------------------- diff --git a/libcloud/test/dns/test_zerigo.py b/libcloud/test/dns/test_zerigo.py index 9bf26f1..de4a5d4 100644 --- a/libcloud/test/dns/test_zerigo.py +++ b/libcloud/test/dns/test_zerigo.py @@ -65,12 +65,15 @@ class ZerigoTests(unittest.TestCase): zone = self.driver.list_zones()[0] records = list(self.driver.list_records(zone=zone)) - self.assertEqual(len(records), 1) + self.assertEqual(len(records), 2) self.assertEqual(records[0].name, 'www') self.assertEqual(records[0].type, RecordType.A) self.assertEqual(records[0].data, '172.16.16.1') self.assertEqual(records[0].extra['fqdn'], 'www.example.com') + self.assertEqual(records[1].name, 'test') + self.assertEqual(records[1].extra['ttl'], 3600) + def test_list_records_no_results(self): zone = self.driver.list_zones()[0] ZerigoMockHttp.type = 'NO_RESULTS'
