Updated Branches: refs/heads/trunk 3fb2097f7 -> a9d375a1f
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/77a0b407 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/77a0b407 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/77a0b407 Branch: refs/heads/trunk Commit: 77a0b407f2b40cc3d70b130f2a505265ba217118 Parents: 3fb2097 Author: Tomaz Muraus <[email protected]> Authored: Fri Sep 6 23:31:45 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Fri Sep 6 23:31:45 2013 +0200 ---------------------------------------------------------------------- CHANGES | 6 ++++++ 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, 28 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/77a0b407/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index 243683f..50f93e3 100644 --- a/CHANGES +++ b/CHANGES @@ -92,6 +92,12 @@ Changes with Apache Libcloud in development constant. [Tomaz Muraus] + *) 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/77a0b407/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/77a0b407/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/77a0b407/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'
