libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [01/15] libcloud git commit: Update old and deprecated per region classes for Rackspace DNS driver.
Date Wed, 06 Apr 2016 15:17:33 GMT
Repository: libcloud
Updated Branches:
  refs/heads/trunk f56db93d7 -> a3b9da4a9


Update old and deprecated per region classes for Rackspace DNS driver.


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

Branch: refs/heads/trunk
Commit: 94d1baa4ff3b09180d9cb7bb14ce972a80a93ed9
Parents: b6ff8db
Author: Tomaz Muraus <tomaz@tomaz.me>
Authored: Wed Mar 16 17:34:50 2016 -0700
Committer: Tomaz Muraus <tomaz@tomaz.me>
Committed: Thu Mar 31 18:32:19 2016 -0700

----------------------------------------------------------------------
 libcloud/dns/drivers/rackspace.py   | 33 +++++++-------------------------
 libcloud/dns/providers.py           | 12 +++++++++++-
 libcloud/dns/types.py               | 10 +++++++++-
 libcloud/test/dns/test_rackspace.py | 15 +++++++++------
 4 files changed, 36 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/94d1baa4/libcloud/dns/drivers/rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/drivers/rackspace.py b/libcloud/dns/drivers/rackspace.py
index 4507fb1..4e0d705 100644
--- a/libcloud/dns/drivers/rackspace.py
+++ b/libcloud/dns/drivers/rackspace.py
@@ -12,16 +12,10 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from libcloud.common.openstack import OpenStackDriverMixin
-
-__all__ = [
-    'RackspaceUSDNSDriver',
-    'RackspaceUKDNSDriver'
-]
-
-from libcloud.utils.py3 import httplib
 import copy
 
+from libcloud.utils.py3 import httplib
+from libcloud.common.openstack import OpenStackDriverMixin
 from libcloud.common.base import PollingConnection
 from libcloud.common.exceptions import BaseHTTPError
 from libcloud.common.types import LibcloudError
@@ -34,6 +28,11 @@ from libcloud.dns.types import Provider, RecordType
 from libcloud.dns.types import ZoneDoesNotExistError, RecordDoesNotExistError
 from libcloud.dns.base import DNSDriver, Zone, Record
 
+__all__ = [
+    'RackspaceDNSResponse',
+    'RackspaceDNSConnection'
+]
+
 VALID_ZONE_EXTRA_PARAMS = ['email', 'comment', 'ns1']
 VALID_RECORD_EXTRA_PARAMS = ['ttl', 'comment', 'priority', 'created',
                              'updated']
@@ -634,24 +633,6 @@ class RackspaceDNSDriver(DNSDriver, OpenStackDriverMixin):
         return kwargs
 
 
-class RackspaceUSDNSDriver(RackspaceDNSDriver):
-    name = 'Rackspace DNS (US)'
-    type = Provider.RACKSPACE_US
-
-    def __init__(self, *args, **kwargs):
-        kwargs['region'] = 'us'
-        super(RackspaceUSDNSDriver, self).__init__(*args, **kwargs)
-
-
-class RackspaceUKDNSDriver(RackspaceDNSDriver):
-    name = 'Rackspace DNS (UK)'
-    type = Provider.RACKSPACE_UK
-
-    def __init__(self, *args, **kwargs):
-        kwargs['region'] = 'uk'
-        super(RackspaceUKDNSDriver, self).__init__(*args, **kwargs)
-
-
 def _rackspace_result_has_more(response, result_length, limit):
     # If rackspace returns less than the limit, then we've reached the end of
     # the result set.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/94d1baa4/libcloud/dns/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/providers.py b/libcloud/dns/providers.py
index c7ad4e4..4f37a9e 100644
--- a/libcloud/dns/providers.py
+++ b/libcloud/dns/providers.py
@@ -14,9 +14,17 @@
 # limitations under the License.
 
 from libcloud.dns.types import Provider
+from libcloud.dns.types import OLD_CONSTANT_TO_NEW_MAPPING
 from libcloud.common.providers import get_driver as _get_provider_driver
 from libcloud.common.providers import set_driver as _set_provider_driver
 
+__all__ = [
+    'DRIVERS',
+
+    'get_driver',
+    'set_driver'
+]
+
 DRIVERS = {
     Provider.DUMMY:
     ('libcloud.dns.drivers.dummy', 'DummyDNSDriver'),
@@ -69,7 +77,9 @@ DRIVERS = {
 
 
 def get_driver(provider):
-    return _get_provider_driver(drivers=DRIVERS, provider=provider)
+    deprecated_constants = OLD_CONSTANT_TO_NEW_MAPPING
+    return _get_provider_driver(drivers=DRIVERS, provider=provider,
+                                deprecated_constants=deprecated_constants)
 
 
 def set_driver(provider, module, klass):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/94d1baa4/libcloud/dns/types.py
----------------------------------------------------------------------
diff --git a/libcloud/dns/types.py b/libcloud/dns/types.py
index 4fba3b2..91111ed 100644
--- a/libcloud/dns/types.py
+++ b/libcloud/dns/types.py
@@ -23,7 +23,9 @@ __all__ = [
     'ZoneAlreadyExistsError',
     'RecordError',
     'RecordDoesNotExistError',
-    'RecordAlreadyExistsError'
+    'RecordAlreadyExistsError',
+
+    'OLD_CONSTANT_TO_NEW_MAPPING'
 ]
 
 
@@ -56,6 +58,12 @@ class Provider(object):
     RACKSPACE_UK = 'rackspace_uk'
 
 
+OLD_CONSTANT_TO_NEW_MAPPING = {
+    Provider.RACKSPACE_US: Provider.RACKSPACE,
+    Provider.RACKSPACE_UK: Provider.RACKSPACE,
+}
+
+
 class RecordType(object):
     """
     DNS record type.

http://git-wip-us.apache.org/repos/asf/libcloud/blob/94d1baa4/libcloud/test/dns/test_rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/test/dns/test_rackspace.py b/libcloud/test/dns/test_rackspace.py
index aa8ad10..0679f05 100644
--- a/libcloud/test/dns/test_rackspace.py
+++ b/libcloud/test/dns/test_rackspace.py
@@ -22,8 +22,7 @@ from libcloud.compute.base import Node
 from libcloud.dns.types import RecordType, ZoneDoesNotExistError
 from libcloud.dns.types import RecordDoesNotExistError
 from libcloud.dns.drivers.rackspace import RackspacePTRRecord
-from libcloud.dns.drivers.rackspace import RackspaceUSDNSDriver
-from libcloud.dns.drivers.rackspace import RackspaceUKDNSDriver
+from libcloud.dns.drivers.rackspace import RackspaceDNSDriver
 from libcloud.loadbalancer.base import LoadBalancer
 
 from libcloud.test import MockHttp
@@ -47,14 +46,17 @@ RDNS_LB = LoadBalancer('370b0ff8-3f57-4e10-ac84-e9145ce005841', 'server1',
 
 
 class RackspaceUSTests(unittest.TestCase):
-    klass = RackspaceUSDNSDriver
+    klass = RackspaceDNSDriver
     endpoint_url = 'https://dns.api.rackspacecloud.com/v1.0/11111'
+    region = 'us'
 
     def setUp(self):
         self.klass.connectionCls.conn_classes = (
             None, RackspaceMockHttp)
         RackspaceMockHttp.type = None
-        self.driver = self.klass(*DNS_PARAMS_RACKSPACE)
+
+        driver_kwargs = {'region': self.region}
+        self.driver = self.klass(*DNS_PARAMS_RACKSPACE, **driver_kwargs)
         self.driver.connection.poll_interval = 0.0
         # normally authentication happens lazily, but we force it here
         self.driver.connection._populate_hosts_and_request_paths()
@@ -85,7 +87,7 @@ class RackspaceUSTests(unittest.TestCase):
                          driver.connection._auth_version)
 
     def test_gets_auth_2_0_endpoint(self):
-        kwargs = {'ex_force_auth_version': '2.0_password'}
+        kwargs = {'ex_force_auth_version': '2.0_password', 'region': self.region}
         driver = self.klass(*DNS_PARAMS_RACKSPACE, **kwargs)
         driver.connection._populate_hosts_and_request_paths()
 
@@ -404,8 +406,9 @@ class RackspaceUSTests(unittest.TestCase):
 
 
 class RackspaceUKTests(RackspaceUSTests):
-    klass = RackspaceUKDNSDriver
+    klass = RackspaceDNSDriver
     endpoint_url = 'https://lon.dns.api.rackspacecloud.com/v1.0/11111'
+    region = 'uk'
 
 
 class RackspaceMockHttp(MockHttp):


Mime
View raw message