]> 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>
Fri, 16 Oct 2015 16:53:02 +0000 (17:53 +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 01a61614379b38c983cdaa179d36694506ee6438..baab93878e715d6e687ffa3a7b923b95403d7e36 100644 (file)
@@ -1516,6 +1516,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):