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 2013/09/15 23:43:18 UTC
[2/2] git commit: Update Azure driver - host argument should have
precedence over key argument.
Update Azure driver - host argument should have precedence over key argument.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/5888d45c
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/5888d45c
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/5888d45c
Branch: refs/heads/trunk
Commit: 5888d45c000ba3045ba03cb845a8191a822409e6
Parents: f12fdf6
Author: Tomaz Muraus <to...@apache.org>
Authored: Sun Sep 15 23:40:17 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Sun Sep 15 23:40:17 2013 +0200
----------------------------------------------------------------------
libcloud/storage/drivers/azure_blobs.py | 11 ++++++++---
libcloud/test/storage/test_azure_blobs.py | 6 ++++++
2 files changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5888d45c/libcloud/storage/drivers/azure_blobs.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/azure_blobs.py b/libcloud/storage/drivers/azure_blobs.py
index 69c9b50..d693f3d 100644
--- a/libcloud/storage/drivers/azure_blobs.py
+++ b/libcloud/storage/drivers/azure_blobs.py
@@ -176,6 +176,7 @@ class AzureBlobsStorageDriver(StorageDriver):
def __init__(self, key, secret=None, secure=True, host=None, port=None,
**kwargs):
+ self._host_argument_set = bool(host)
# B64decode() this key and keep it, so that we don't have to do
# so for every request. Minor performance improvement
@@ -187,9 +188,13 @@ class AzureBlobsStorageDriver(StorageDriver):
port=port, **kwargs)
def _ex_connection_class_kwargs(self):
- return {
- 'host': '%s.%s' % (self.key, AZURE_STORAGE_HOST_SUFFIX),
- }
+ result = {}
+
+ # host argument has precedence
+ if not self._host_argument_set:
+ result['host'] = '%s.%s' % (self.key, AZURE_STORAGE_HOST_SUFFIX)
+
+ return result
def _xml_to_container(self, node):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/5888d45c/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 faf2d19..78f1f80 100644
--- a/libcloud/test/storage/test_azure_blobs.py
+++ b/libcloud/test/storage/test_azure_blobs.py
@@ -939,10 +939,16 @@ class AzureBlobsTests(unittest.TestCase):
# management of the connectionCls.host class attribute
driver1 = self.driver_type('fakeaccount1', 'deadbeafcafebabe==')
driver2 = self.driver_type('fakeaccount2', 'deadbeafcafebabe==')
+ driver3 = self.driver_type('fakeaccount3', 'deadbeafcafebabe==',
+ host='test.foo.bar.com')
+
host1 = driver1.connection.host
host2 = driver2.connection.host
+ host3 = driver3.connection.host
+
self.assertEquals(host1, 'fakeaccount1.blob.core.windows.net')
self.assertEquals(host2, 'fakeaccount2.blob.core.windows.net')
+ self.assertEquals(host3, 'test.foo.bar.com')
if __name__ == '__main__':