libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1226328 - in /libcloud/trunk/libcloud/dns: base.py drivers/linode.py drivers/rackspace.py drivers/zerigo.py
Date Mon, 02 Jan 2012 00:58:29 GMT
Author: tomaz
Date: Mon Jan  2 00:58:28 2012
New Revision: 1226328

URL: http://svn.apache.org/viewvc?rev=1226328&view=rev
Log:
Add list_record_types method to the base DNSDriver class.

Modified:
    libcloud/trunk/libcloud/dns/base.py
    libcloud/trunk/libcloud/dns/drivers/linode.py
    libcloud/trunk/libcloud/dns/drivers/rackspace.py
    libcloud/trunk/libcloud/dns/drivers/zerigo.py

Modified: libcloud/trunk/libcloud/dns/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/base.py?rev=1226328&r1=1226327&r2=1226328&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/base.py (original)
+++ libcloud/trunk/libcloud/dns/base.py Mon Jan  2 00:58:28 2012
@@ -142,8 +142,7 @@ class DNSDriver(BaseDriver):
 
         @return: A list of C{RecordType} instances.
         """
-        raise NotImplementedError(
-            'list_record_types not implemented for this driver')
+        return list(self.RECORD_TYPE_MAP.keys())
 
     def list_zones(self):
         """

Modified: libcloud/trunk/libcloud/dns/drivers/linode.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/linode.py?rev=1226328&r1=1226327&r2=1226328&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/linode.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/linode.py Mon Jan  2 00:58:28 2012
@@ -33,16 +33,6 @@ VALID_ZONE_EXTRA_PARAMS = ['SOA_Email', 
 VALID_RECORD_EXTRA_PARAMS = ['Priority', 'Weight', 'Port', 'Protocol',
                              'TTL_sec']
 
-RECORD_TYPE_MAP = {
-    RecordType.NS: 'NS',
-    RecordType.MX: 'MX',
-    RecordType.A: 'A',
-    RecordType.AAAA: 'AAAA',
-    RecordType.CNAME: 'CNAME',
-    RecordType.TXT: 'TXT',
-    RecordType.SRV: 'SRV',
-}
-
 
 class LinodeDNSResponse(LinodeResponse):
     def _make_excp(self, error):
@@ -71,8 +61,15 @@ class LinodeDNSDriver(DNSDriver):
     name = 'Linode DNS'
     connectionCls = LinodeDNSConnection
 
-    def list_record_types(self):
-        return list(RECORD_TYPE_MAP.keys())
+    RECORD_TYPE_MAP = {
+        RecordType.NS: 'NS',
+        RecordType.MX: 'MX',
+        RecordType.A: 'A',
+        RecordType.AAAA: 'AAAA',
+        RecordType.CNAME: 'CNAME',
+        RecordType.TXT: 'TXT',
+        RecordType.SRV: 'SRV',
+    }
 
     def list_zones(self):
         params = {'api_action': 'domain.list'}
@@ -166,7 +163,8 @@ class LinodeDNSDriver(DNSDriver):
         API docs: http://www.linode.com/api/dns/domain.resource.create
         """
         params = {'api_action': 'domain.resource.create', 'DomainID': zone.id,
-                  'Name': name, 'Target': data, 'Type': RECORD_TYPE_MAP[type]}
+                  'Name': name, 'Target': data,
+                  'Type': self.RECORD_TYPE_MAP[type]}
         merged = merge_valid_keys(params=params,
                                   valid_keys=VALID_RECORD_EXTRA_PARAMS,
                                   extra=extra)
@@ -193,7 +191,7 @@ class LinodeDNSDriver(DNSDriver):
             params['Target'] = data
 
         if type:
-            params['Type'] = RECORD_TYPE_MAP[type]
+            params['Type'] = self.RECORD_TYPE_MAP[type]
 
         merged = merge_valid_keys(params=params,
                                   valid_keys=VALID_RECORD_EXTRA_PARAMS,

Modified: libcloud/trunk/libcloud/dns/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/rackspace.py?rev=1226328&r1=1226327&r2=1226328&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/rackspace.py Mon Jan  2 00:58:28 2012
@@ -35,16 +35,6 @@ from libcloud.dns.base import DNSDriver,
 VALID_ZONE_EXTRA_PARAMS = ['email', 'comment', 'ns1']
 VALID_RECORD_EXTRA_PARAMS = ['ttl', 'comment']
 
-RECORD_TYPE_MAP = {
-    RecordType.A: 'A',
-    RecordType.AAAA: 'AAAA',
-    RecordType.CNAME: 'CNAME',
-    RecordType.MX: 'MX',
-    RecordType.NS: 'NS',
-    RecordType.TXT: 'TXT',
-    RecordType.SRV: 'SRV',
-}
-
 
 class RackspaceDNSResponse(OpenStack_1_1_Response):
     """
@@ -111,8 +101,16 @@ class RackspaceUKDNSConnection(Rackspace
 
 
 class RackspaceDNSDriver(DNSDriver):
-    def list_record_types(self):
-        return list(RECORD_TYPE_MAP.keys())
+
+    RECORD_TYPE_MAP = {
+        RecordType.A: 'A',
+        RecordType.AAAA: 'AAAA',
+        RecordType.CNAME: 'CNAME',
+        RecordType.MX: 'MX',
+        RecordType.NS: 'NS',
+        RecordType.TXT: 'TXT',
+        RecordType.SRV: 'SRV',
+    }
 
     def list_zones(self):
         response = self.connection.request(action='/domains')
@@ -202,7 +200,8 @@ class RackspaceDNSDriver(DNSDriver):
         extra = extra if extra else {}
 
         name = self._to_full_record_name(domain=zone.domain, name=name)
-        data = {'name': name, 'type': RECORD_TYPE_MAP[type], 'data': data}
+        data = {'name': name, 'type': self.RECORD_TYPE_MAP[type],
+                'data': data}
 
         if 'ttl' in extra:
             data['ttl'] = int(extra['ttl'])

Modified: libcloud/trunk/libcloud/dns/drivers/zerigo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/zerigo.py?rev=1226328&r1=1226327&r2=1226328&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/zerigo.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/zerigo.py Mon Jan  2 00:58:28 2012
@@ -45,20 +45,6 @@ VALID_RECORD_EXTRA_PARAMS = ['notes', 't
 # Number of items per page (maximum limit is 1000)
 ITEMS_PER_PAGE = 100
 
-RECORD_TYPE_MAP = {
-    RecordType.A: 'A',
-    RecordType.AAAA: 'AAAA',
-    RecordType.CNAME: 'CNAME',
-    RecordType.MX: 'MX',
-    RecordType.REDIRECT: 'REDIRECT',
-    RecordType.TXT: 'TXT',
-    RecordType.SRV: 'SRV',
-    RecordType.NAPTR: 'NAPTR',
-    RecordType.NS: 'NS',
-    RecordType.PTR: 'PTR',
-    RecordType.SPF: 'SPF',
-}
-
 
 class ZerigoError(LibcloudError):
     def __init__(self, code, errors):
@@ -141,8 +127,19 @@ class ZerigoDNSDriver(DNSDriver):
     name = 'Zerigo DNS'
     connectionCls = ZerigoDNSConnection
 
-    def list_record_types(self):
-        return list(RECORD_TYPE_MAP.keys())
+    RECORD_TYPE_MAP = {
+        RecordType.A: 'A',
+        RecordType.AAAA: 'AAAA',
+        RecordType.CNAME: 'CNAME',
+        RecordType.MX: 'MX',
+        RecordType.REDIRECT: 'REDIRECT',
+        RecordType.TXT: 'TXT',
+        RecordType.SRV: 'SRV',
+        RecordType.NAPTR: 'NAPTR',
+        RecordType.NS: 'NS',
+        RecordType.PTR: 'PTR',
+        RecordType.SPF: 'SPF',
+    }
 
     def list_zones(self):
         value_dict = {'type': 'zones'}
@@ -332,7 +329,7 @@ class ZerigoDNSDriver(DNSDriver):
 
         if type:
             type_elem = ET.SubElement(record_elem, 'host-type')
-            type_elem.text = RECORD_TYPE_MAP[type]
+            type_elem.text = self.RECORD_TYPE_MAP[type]
 
         if data:
             data_elem = ET.SubElement(record_elem, 'data')



Mime
View raw message