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 2013/12/05 16:31:47 UTC

[1/2] git commit: [LIBCLOUD-434] Implement iterate_* methods in the Route53 driver.

Updated Branches:
  refs/heads/trunk 12a75c9fe -> a84a01a44


[LIBCLOUD-434] Implement iterate_* methods in the Route53 driver.

This way all the records are returned and not just the ones which fit onto the
first page.

Signed-off-by: Tomaz Muraus <to...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a2e23040
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a2e23040
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a2e23040

Branch: refs/heads/trunk
Commit: a2e23040d8f98335238ab7b793ac316871e1f0c5
Parents: 12a75c9
Author: xofer <ch...@parsely.com>
Authored: Thu Dec 5 03:21:23 2013 -0500
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 5 16:24:46 2013 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/route53.py | 52 +++++++++++++++++++++++++++++-------
 1 file changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a2e23040/libcloud/dns/drivers/route53.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/route53.py b/libcloud/dns/drivers/route53.py
index cb82379..ae128e4 100644
--- a/libcloud/dns/drivers/route53.py
+++ b/libcloud/dns/drivers/route53.py
@@ -111,17 +111,11 @@ class Route53DNSDriver(DNSDriver):
         RecordType.TXT: 'TXT'
     }
 
-    def list_zones(self):
-        data = self.connection.request(API_ROOT + 'hostedzone').object
-        zones = self._to_zones(data=data)
-        return zones
+    def iterate_zones(self):
+        return self._get_more('zones')
 
-    def list_records(self, zone):
-        self.connection.set_context({'zone_id': zone.id})
-        uri = API_ROOT + 'hostedzone/' + zone.id + '/rrset'
-        data = self.connection.request(uri).object
-        records = self._to_records(data=data, zone=zone)
-        return records
+    def iterate_records(self, zone):
+        return self._get_more('records', zone=zone)
 
     def get_zone(self, zone_id):
         self.connection.set_context({'zone_id': zone_id})
@@ -308,3 +302,41 @@ class Route53DNSDriver(DNSDriver):
         record = Record(id=id, name=name, type=type, data=data, zone=zone,
                         driver=self, extra=extra)
         return record
+
+    def _get_more(self, rtype, **kwargs):
+        exhausted = False
+        last_key = None
+        while not exhausted:
+            items, last_key, exhausted = self._get_data(rtype, last_key,
+                                                        **kwargs)
+            for item in items:
+                yield item
+
+    def _get_data(self, rtype, last_key, **kwargs):
+        params = {}
+        if last_key:
+            params['name'] = last_key
+        path = API_ROOT + 'hostedzone'
+
+        if rtype == 'zones':
+            response = self.connection.request(path, params=params)
+            transform_func = self._to_zones
+        elif rtype == 'records':
+            zone = kwargs['zone']
+            path += '/%s/rrset' % (zone.id)
+            self.connection.set_context({'zone_id': zone.id})
+            response = self.connection.request(path, params=params)
+            transform_func = self._to_records
+
+        if response.status == httplib.OK:
+            is_truncated = findtext(element=response.object,
+                                    xpath='IsTruncated',
+                                    namespace=NAMESPACE)
+            exhausted = is_truncated != 'true'
+            last_key = findtext(element=response.object,
+                                xpath='NextRecordName',
+                                namespace=NAMESPACE)
+            items = transform_func(data=response.object, **kwargs)
+            return items, last_key, exhausted
+        else:
+            return [], None, True


[2/2] git commit: Update CHANGES.

Posted by to...@apache.org.
Update CHANGES.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/a84a01a4
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/a84a01a4
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/a84a01a4

Branch: refs/heads/trunk
Commit: a84a01a44b65b818fbf36eeff455b7fd572a2f27
Parents: a2e2304
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Dec 5 16:27:49 2013 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Dec 5 16:27:49 2013 +0100

----------------------------------------------------------------------
 CHANGES | 7 +++++++
 1 file changed, 7 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a84a01a4/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 6470439..ed2e4c5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -70,6 +70,13 @@ Changes with Apache Libcloud in development
       Rackspace drivers to use auth 2.0 by default.
       [John Obelenus]
 
+  *) DNS
+
+    - Implement iterate_* methods in the Route53 driver and makes it work
+      correctly if there are more results which can fit on a single page.
+      Previously, only first 100 results were returned. (LIBCLOUD-434)
+      [Chris Clarke]
+
 Changes with Apache Libcloud 0.14.0-beta3
 
   *) General