]> 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, 17 Apr 2015 21:31:40 +0000 (22:31 +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 2a91d839e98ccca64d3bffa048b74f1f8f78ecb2..21a579e6a245a58707ac8a8af6c43ec617dbf1e2 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):