From: Itamar Turner-Trauring Date: Thu, 16 May 2013 17:49:43 +0000 (-0400) Subject: Implement method to create containers in Microsoft Azure storage backend. X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=7adbe6e5ec9d1f1cd37d3d279c608acb4dde8628;p=tahoe-lafs%2Ftahoe-lafs.git Implement method to create containers in Microsoft Azure storage backend. --- diff --git a/src/allmydata/storage/backends/cloud/msazure/msazure_container.py b/src/allmydata/storage/backends/cloud/msazure/msazure_container.py index 59019e17..11303d05 100644 --- a/src/allmydata/storage/backends/cloud/msazure/msazure_container.py +++ b/src/allmydata/storage/backends/cloud/msazure/msazure_container.py @@ -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): """ diff --git a/src/allmydata/test/test_storage.py b/src/allmydata/test/test_storage.py index bb9b3e08..2b7843eb 100644 --- a/src/allmydata/test/test_storage.py +++ b/src/allmydata/test/test_storage.py @@ -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):