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 2016/04/06 17:17:34 UTC

[02/15] libcloud git commit: Also handle deprecated constant mapping for storage drivers and update affected CloudFiles drivers.

Also handle deprecated constant mapping for storage drivers and update affected
CloudFiles drivers.


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

Branch: refs/heads/trunk
Commit: 41b9caa64d7ee6500235c6d4c2bf2b6187f766fa
Parents: 2f73fdf
Author: Tomaz Muraus <to...@tomaz.me>
Authored: Wed Mar 16 16:18:13 2016 -0700
Committer: Tomaz Muraus <to...@tomaz.me>
Committed: Thu Mar 31 18:32:19 2016 -0700

----------------------------------------------------------------------
 libcloud/compute/providers.py            |  3 ++-
 libcloud/compute/types.py                |  1 +
 libcloud/storage/providers.py            | 13 ++++--------
 libcloud/storage/types.py                | 30 +++++++++++++++++++--------
 libcloud/test/compute/test_rackspace.py  |  1 -
 libcloud/test/storage/test_cloudfiles.py | 11 +++++-----
 6 files changed, 34 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/41b9caa6/libcloud/compute/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/providers.py b/libcloud/compute/providers.py
index b186757..568c886 100644
--- a/libcloud/compute/providers.py
+++ b/libcloud/compute/providers.py
@@ -145,9 +145,10 @@ DRIVERS = {
 
 
 def get_driver(provider):
+    deprecated_constants = OLD_CONSTANT_TO_NEW_MAPPING
     return _get_provider_driver(drivers=DRIVERS, provider=provider,
                                 deprecated_providers=DEPRECATED_DRIVERS,
-                                deprecated_constants=OLD_CONSTANT_TO_NEW_MAPPING)
+                                deprecated_constants=deprecated_constants)
 
 
 def set_driver(provider, module, klass):

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41b9caa6/libcloud/compute/types.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/types.py b/libcloud/compute/types.py
index 17f9ef5..5b9b768 100644
--- a/libcloud/compute/types.py
+++ b/libcloud/compute/types.py
@@ -30,6 +30,7 @@ __all__ = [
     "MalformedResponseError",
     "InvalidCredsError",
     "InvalidCredsException",
+
     "OLD_CONSTANT_TO_NEW_MAPPING"
 ]
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41b9caa6/libcloud/storage/providers.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/providers.py b/libcloud/storage/providers.py
index 0eaaf8c..eddd470 100644
--- a/libcloud/storage/providers.py
+++ b/libcloud/storage/providers.py
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 from libcloud.storage.types import Provider
+from libcloud.storage.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
 
@@ -62,19 +63,13 @@ DRIVERS = {
     ('libcloud.storage.drivers.backblaze_b2', 'BackblazeB2StorageDriver'),
     Provider.ALIYUN_OSS:
     ('libcloud.storage.drivers.oss', 'OSSStorageDriver'),
-
-    # Deprecated
-    Provider.CLOUDFILES_US:
-    ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUSStorageDriver'),
-    Provider.CLOUDFILES_UK:
-    ('libcloud.storage.drivers.cloudfiles', 'CloudFilesUKStorageDriver'),
-    Provider.CLOUDFILES_SWIFT:
-    ('libcloud.storage.drivers.cloudfiles', 'OpenStackSwiftStorageDriver')
 }
 
 
 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/41b9caa6/libcloud/storage/types.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/types.py b/libcloud/storage/types.py
index 131d4f6..ea8f645 100644
--- a/libcloud/storage/types.py
+++ b/libcloud/storage/types.py
@@ -15,15 +15,19 @@
 
 from libcloud.common.types import LibcloudError
 
-__all__ = ['Provider',
-           'ContainerError',
-           'ObjectError',
-           'ContainerAlreadyExistsError',
-           'ContainerDoesNotExistError',
-           'ContainerIsNotEmptyError',
-           'ObjectDoesNotExistError',
-           'ObjectHashMismatchError',
-           'InvalidContainerNameError']
+__all__ = [
+    'Provider',
+    'ContainerError',
+    'ObjectError',
+    'ContainerAlreadyExistsError',
+    'ContainerDoesNotExistError',
+    'ContainerIsNotEmptyError',
+    'ObjectDoesNotExistError',
+    'ObjectHashMismatchError',
+    'InvalidContainerNameError',
+
+    'OLD_CONSTANT_TO_NEW_MAPPING'
+]
 
 
 class Provider(object):
@@ -75,6 +79,14 @@ class Provider(object):
     CLOUDFILES_SWIFT = 'cloudfiles_swift'
 
 
+OLD_CONSTANT_TO_NEW_MAPPING = {
+    # CloudFiles
+    Provider.CLOUDFILES_US: Provider.CLOUDFILES,
+    Provider.CLOUDFILES_UK: Provider.CLOUDFILES_UK,
+    Provider.CLOUDFILES_SWIFT: Provider.OPENSTACK_SWIFT
+}
+
+
 class ContainerError(LibcloudError):
     error_type = 'ContainerError'
 

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41b9caa6/libcloud/test/compute/test_rackspace.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_rackspace.py b/libcloud/test/compute/test_rackspace.py
index 581b198..d5e46cb 100644
--- a/libcloud/test/compute/test_rackspace.py
+++ b/libcloud/test/compute/test_rackspace.py
@@ -51,7 +51,6 @@ class RackspaceusFirstGenUsTests(OpenStack_1_0_Tests):
                 get_driver(provider)
             except Exception:
                 e = sys.exc_info()[1]
-                print str(e)
                 self.assertTrue(str(e).find('has been removed') != -1)
             else:
                 self.fail('Exception was not thrown')

http://git-wip-us.apache.org/repos/asf/libcloud/blob/41b9caa6/libcloud/test/storage/test_cloudfiles.py
----------------------------------------------------------------------
diff --git a/libcloud/test/storage/test_cloudfiles.py b/libcloud/test/storage/test_cloudfiles.py
index 3e911da..58e1e18 100644
--- a/libcloud/test/storage/test_cloudfiles.py
+++ b/libcloud/test/storage/test_cloudfiles.py
@@ -38,8 +38,6 @@ from libcloud.storage.types import ObjectDoesNotExistError
 from libcloud.storage.types import ObjectHashMismatchError
 from libcloud.storage.types import InvalidContainerNameError
 from libcloud.storage.drivers.cloudfiles import CloudFilesStorageDriver
-from libcloud.storage.drivers.cloudfiles import CloudFilesUSStorageDriver
-from libcloud.storage.drivers.cloudfiles import CloudFilesUKStorageDriver
 from libcloud.storage.drivers.dummy import DummyIterator
 
 from libcloud.test import StorageMockHttp, MockRawResponse  # pylint: disable-msg=E0611
@@ -61,8 +59,11 @@ class CloudFilesTests(unittest.TestCase):
             CloudFilesMockRawResponse
         CloudFilesMockHttp.type = None
         CloudFilesMockRawResponse.type = None
+
+        driver_kwargs = self.driver_kwargs.copy()
+        driver_kwargs['region'] = self.region
         self.driver = self.driver_klass(*self.driver_args,
-                                        **self.driver_kwargs)
+                                        **driver_kwargs)
 
         # normally authentication happens lazily, but we force it here
         self.driver.connection._populate_hosts_and_request_paths()
@@ -866,12 +867,12 @@ class CloudFilesTests(unittest.TestCase):
 
 
 class CloudFilesDeprecatedUSTests(CloudFilesTests):
-    driver_klass = CloudFilesUSStorageDriver
+    driver_klass = CloudFilesStorageDriver
     region = 'ord'
 
 
 class CloudFilesDeprecatedUKTests(CloudFilesTests):
-    driver_klass = CloudFilesUKStorageDriver
+    driver_klass = CloudFilesStorageDriver
     region = 'lon'