Modify Rackspace DNS driver to set record name to None for the records
which correspond to the root domain.

This is done for consistency with other drivers.


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

Branch: refs/heads/trunk
Commit: 81028e66d9a87392c0e58ba329b12895c0ca6b57
Parents: 4cf0088
Author: Tomaz Muraus <[email protected]>
Authored: Sat Jan 18 01:22:27 2014 +0100
Committer: Tomaz Muraus <[email protected]>
Committed: Sat Jan 18 01:22:27 2014 +0100

----------------------------------------------------------------------
 libcloud/dns/drivers/rackspace.py   |  8 +++++++-
 libcloud/test/dns/test_rackspace.py | 11 +++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/81028e66/libcloud/dns/drivers/rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/rackspace.py 
b/libcloud/dns/drivers/rackspace.py
index f56a993..3410742 100644
--- a/libcloud/dns/drivers/rackspace.py
+++ b/libcloud/dns/drivers/rackspace.py
@@ -373,7 +373,7 @@ class RackspaceDNSDriver(DNSDriver, OpenStackDriverMixin):
 
     def _to_partial_record_name(self, domain, name):
         """
-        Strip domain portion from the record name.
+        Remove domain portion from the record name.
 
         :param domain: Domain name.
         :type domain: ``str``
@@ -381,6 +381,12 @@ class RackspaceDNSDriver(DNSDriver, OpenStackDriverMixin):
         :param name: Full record name (fqdn).
         :type name: ``str``
         """
+        if name == domain:
+            # Map "root" record names to None to be consistent with other
+            # drivers
+            return None
+
+        # Strip domain portion
         name = name.replace('.%s' % (domain), '')
         return name
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/81028e66/libcloud/test/dns/test_rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_rackspace.py 
b/libcloud/test/dns/test_rackspace.py
index 0afc337..4a211a3 100644
--- a/libcloud/test/dns/test_rackspace.py
+++ b/libcloud/test/dns/test_rackspace.py
@@ -309,6 +309,17 @@ class RackspaceUSTests(unittest.TestCase):
         self.assertEqual(self.driver._to_full_record_name(domain, name),
                          'foo.bar')
 
+    def test_to_partial_record_name(self):
+        domain = 'example.com'
+        names = ['test.example.com', 'foo.bar.example.com',
+                 'example.com.example.com', 'example.com']
+        expected_values = ['test', 'foo.bar', 'example.com', None]
+
+        for name, expected_value in zip(names, expected_values):
+            value = self.driver._to_partial_record_name(domain=domain,
+                                                        name=name)
+            self.assertEqual(value, expected_value)
+
 
 class RackspaceUKTests(RackspaceUSTests):
     klass = RackspaceUKDNSDriver

Reply via email to