Updated Branches: refs/heads/trunk 163f9811d -> 8f815ab6f
LIBCLOUD-399: avoid mutating AzureBlobsConnection at driver instance time Signed-off-by: Tomaz Muraus <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/79444117 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/79444117 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/79444117 Branch: refs/heads/trunk Commit: 79444117414be2aba91bd8c44d7abc9bd66dc37d Parents: 163f981 Author: Olivier Grisel <[email protected]> Authored: Sun Sep 15 18:11:57 2013 +0200 Committer: Tomaz Muraus <[email protected]> Committed: Sun Sep 15 22:49:06 2013 +0200 ---------------------------------------------------------------------- libcloud/storage/drivers/azure_blobs.py | 11 +++++++---- libcloud/test/storage/test_azure_blobs.py | 11 +++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/79444117/libcloud/storage/drivers/azure_blobs.py ---------------------------------------------------------------------- diff --git a/libcloud/storage/drivers/azure_blobs.py b/libcloud/storage/drivers/azure_blobs.py index 06e4511..69c9b50 100644 --- a/libcloud/storage/drivers/azure_blobs.py +++ b/libcloud/storage/drivers/azure_blobs.py @@ -75,6 +75,8 @@ AZURE_PAGE_CHUNK_SIZE = 512 # released using the lease_id (which is not exposed to the user) AZURE_LEASE_PERIOD = 60 +AZURE_STORAGE_HOST_SUFFIX = 'blob.core.windows.net' + class AzureBlobLease(object): """ @@ -162,7 +164,6 @@ class AzureBlobsConnection(AzureConnection): """ Represents a single connection to Azure Blobs """ - host = 'blob.core.windows.net' class AzureBlobsStorageDriver(StorageDriver): @@ -176,9 +177,6 @@ class AzureBlobsStorageDriver(StorageDriver): def __init__(self, key, secret=None, secure=True, host=None, port=None, **kwargs): - # The hostname must be 'account.blobs.core.windows.net' - self.connectionCls.host = '%s.%s' % (key, self.connectionCls.host) - # B64decode() this key and keep it, so that we don't have to do # so for every request. Minor performance improvement secret = base64.b64decode(b(secret)) @@ -188,6 +186,11 @@ class AzureBlobsStorageDriver(StorageDriver): secure=secure, host=host, port=port, **kwargs) + def _ex_connection_class_kwargs(self): + return { + 'host': '%s.%s' % (self.key, AZURE_STORAGE_HOST_SUFFIX), + } + def _xml_to_container(self, node): """ Converts a container XML node to a container instance http://git-wip-us.apache.org/repos/asf/libcloud/blob/79444117/libcloud/test/storage/test_azure_blobs.py ---------------------------------------------------------------------- diff --git a/libcloud/test/storage/test_azure_blobs.py b/libcloud/test/storage/test_azure_blobs.py index 3255d9d..faf2d19 100644 --- a/libcloud/test/storage/test_azure_blobs.py +++ b/libcloud/test/storage/test_azure_blobs.py @@ -934,5 +934,16 @@ class AzureBlobsTests(unittest.TestCase): result = self.driver.delete_object(obj=obj) self.assertTrue(result) + def test_storage_driver_host(self): + # Non regression tests for issue LIBCLOUD-399 dealing with the bad + # management of the connectionCls.host class attribute + driver1 = self.driver_type('fakeaccount1', 'deadbeafcafebabe==') + driver2 = self.driver_type('fakeaccount2', 'deadbeafcafebabe==') + host1 = driver1.connection.host + host2 = driver2.connection.host + self.assertEquals(host1, 'fakeaccount1.blob.core.windows.net') + self.assertEquals(host2, 'fakeaccount2.blob.core.windows.net') + + if __name__ == '__main__': sys.exit(unittest.main())
