]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Implement method to create containers in Microsoft Azure storage backend.
authorItamar Turner-Trauring <itamar@futurefoundries.com>
Thu, 16 May 2013 17:49:43 +0000 (13:49 -0400)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 9 Apr 2014 00:44:25 +0000 (01:44 +0100)
src/allmydata/storage/backends/cloud/msazure/msazure_container.py
src/allmydata/test/test_storage.py

index 59019e175e9c3be64f98ad298fa91a9a82e4ce4e..11303d056890f094211e3d1167c0b0a976ad0c52 100644 (file)
@@ -214,6 +214,18 @@ class MSAzureStorageContainer(CommonContainerMixin):
         d.addCallback(lambda (response, body): body)
         return d
 
+    def _create(self):
+        """
+        Create the container.
+        """
+        url = self._make_container_url(self.URI)
+        url += "?restype=container"
+        d = self._authorized_http_request("MS Azure PUT container", 'PUT',
+                                          url, {}, body=None,
+                                          need_response_body=False)
+        d.addCallback(lambda (response, body): body)
+        return d
+
 
 def configure_msazure_container(storedir, config):
     """
index 8973c5aab62495242b970b86ee743e1432f3d407..2e9968cca88f1b0bd7cd5301c404407ec97d547c 100644 (file)
@@ -1509,6 +1509,27 @@ class MSAzureStorageBackendTests(unittest.TestCase, CloudStorageBackendMixin):
         http_response.callback((self.Response(200), None))
         self.failUnless(done)
 
+    def test_create_container(self):
+        """
+        MSAzureStorageContainer.create() send the appropriate HTTP command to
+        create the container (aka bucket).
+        """
+        http_response = self.mock_http_request()
+        done = []
+        self.container.create().addCallback(done.append)
+        self.failIf(done)
+        self.container._http_request.assert_called_once_with(
+            "MS Azure PUT container", "PUT",
+            "https://theaccount.blob.core.windows.net/thebucket?restype=container",
+            {"Authorization": [self.authorization],
+             "x-ms-version": ["2012-02-12"],
+             "x-ms-date": [self.date],
+             },
+            body=None,
+            need_response_body=False)
+        http_response.callback((self.Response(200), None))
+        self.failUnless(done)
+
 
 class ServerMixin:
     def allocate(self, account, storage_index, sharenums, size, canary=None):