]> 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, 10 Jul 2015 04:38:05 +0000 (05:38 +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 bb9b3e087107e97858b2fb5201974fb05bbe363f..2b7843eb7d2be2fe788f12a34990e7720778cc15 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):