libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [7/9] git commit: Update Route53 driver so it also handles SRV records better.
Date Wed, 05 Feb 2014 19:45:03 GMT
Update Route53 driver so it also handles SRV records better.


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

Branch: refs/heads/trunk
Commit: 204d56935ceac76c7507f011b548597f696e9a0c
Parents: 8f2e551
Author: Tomaz Muraus <tomaz@apache.org>
Authored: Wed Feb 5 20:33:37 2014 +0100
Committer: Tomaz Muraus <tomaz@apache.org>
Committed: Wed Feb 5 20:36:57 2014 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/route53.py                     | 10 ++++++++--
 libcloud/test/dns/fixtures/route53/list_records.xml | 16 +++++++++++++++-
 libcloud/test/dns/test_route53.py                   |  9 ++++++++-
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/204d5693/libcloud/dns/drivers/route53.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/route53.py b/libcloud/dns/drivers/route53.py
index 811b7a2..944449b 100644
--- a/libcloud/dns/drivers/route53.py
+++ b/libcloud/dns/drivers/route53.py
@@ -302,8 +302,14 @@ class Route53DNSDriver(DNSDriver):
 
         if type == 'MX':
             split = data.split()
-            priority, data = int(split[0]), split[1]
-            extra['priority'] = priority
+            priority, data = split
+            extra['priority'] = int(priority)
+        elif type == 'SRV':
+            split = data.split()
+            priority, weight, port, data = split
+            extra['priority'] = int(priority)
+            extra['weight'] = int(weight)
+            extra['port'] = int(port)
 
         id = ':'.join((self.RECORD_TYPE_MAP[type], name))
         record = Record(id=id, name=name, type=type, data=data, zone=zone,

http://git-wip-us.apache.org/repos/asf/libcloud/blob/204d5693/libcloud/test/dns/fixtures/route53/list_records.xml
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/fixtures/route53/list_records.xml b/libcloud/test/dns/fixtures/route53/list_records.xml
index ff6a395..b9638fa 100644
--- a/libcloud/test/dns/fixtures/route53/list_records.xml
+++ b/libcloud/test/dns/fixtures/route53/list_records.xml
@@ -56,7 +56,21 @@
                <Value>10 ASPMX3.GOOGLEMAIL.COM.</Value>
             </ResourceRecord>
          </ResourceRecords>
-      </ResourceRecordSet>
+    </ResourceRecordSet>
+
+    <ResourceRecordSet>
+      <Name>foo.test.com.</Name>
+      <Type>SRV</Type>
+      <TTL>300</TTL>
+      <ResourceRecords>
+        <ResourceRecord>
+          <Value>1 10 5269 xmpp-server.example.com.</Value>
+        </ResourceRecord>
+        <ResourceRecord>
+          <Value>2 12 5060 sip-server.example.com.</Value>
+        </ResourceRecord>
+      </ResourceRecords>
+    </ResourceRecordSet>
 
   </ResourceRecordSets>
 </ListResourceRecordSetsResponse>

http://git-wip-us.apache.org/repos/asf/libcloud/blob/204d5693/libcloud/test/dns/test_route53.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_route53.py b/libcloud/test/dns/test_route53.py
index 93355ab..c512a8b 100644
--- a/libcloud/test/dns/test_route53.py
+++ b/libcloud/test/dns/test_route53.py
@@ -50,7 +50,7 @@ class Route53Tests(unittest.TestCase):
     def test_list_records(self):
         zone = self.driver.list_zones()[0]
         records = self.driver.list_records(zone=zone)
-        self.assertEqual(len(records), 8)
+        self.assertEqual(len(records), 10)
 
         record = records[1]
         self.assertEqual(record.name, 'www')
@@ -68,6 +68,13 @@ class Route53Tests(unittest.TestCase):
         self.assertEqual(record.data, 'ALT1.ASPMX.L.GOOGLE.COM.')
         self.assertEqual(record.extra['priority'], 5)
 
+        record = records[8]
+        self.assertEqual(record.type, RecordType.SRV)
+        self.assertEqual(record.data, 'xmpp-server.example.com.')
+        self.assertEqual(record.extra['priority'], 1)
+        self.assertEqual(record.extra['weight'], 10)
+        self.assertEqual(record.extra['port'], 5269)
+
     def test_get_zone(self):
         zone = self.driver.get_zone(zone_id='47234')
         self.assertEqual(zone.id, '47234')


Mime
View raw message