diff options
| author | Zuul <zuul@review.opendev.org> | 2020-03-13 22:53:48 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2020-03-13 22:53:48 +0000 |
| commit | 045f133f16722f1cf429bf2ec30c36df82095acd (patch) | |
| tree | e7a2ed212bce625e8702d4be248a630600eacdcf /openstackclient/api | |
| parent | 37240b3b8311b0d795aa87de23121aed7ab4da7b (diff) | |
| parent | d6022f96dfd608b83a4ff41483336f024aeacb16 (diff) | |
| download | python-openstackclient-045f133f16722f1cf429bf2ec30c36df82095acd.tar.gz | |
Merge "Add storage policy option to create container command"
Diffstat (limited to 'openstackclient/api')
| -rw-r--r-- | openstackclient/api/object_store_v1.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index 44ff7a01..c8514a57 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -24,6 +24,11 @@ from six.moves import urllib from openstackclient.api import api +GLOBAL_READ_ACL = ".r:*" +LIST_CONTENTS_ACL = ".rlistings" +PUBLIC_CONTAINER_ACLS = [GLOBAL_READ_ACL, LIST_CONTENTS_ACL] + + class APIv1(api.BaseAPI): """Object Store v1 API""" @@ -33,15 +38,32 @@ class APIv1(api.BaseAPI): def container_create( self, container=None, + public=False, + storage_policy=None ): """Create a container :param string container: name of container to create + :param bool public: + Boolean value indicating if the container should be publicly + readable. Defaults to False. + :param string storage_policy: + Name of the a specific storage policy to use. If not specified + swift will use its default storage policy. :returns: dict of returned headers """ - response = self.create(urllib.parse.quote(container), method='PUT') + + headers = {} + if public: + headers['x-container-read'] = ",".join(PUBLIC_CONTAINER_ACLS) + if storage_policy is not None: + headers['x-storage-policy'] = storage_policy + + response = self.create( + urllib.parse.quote(container), method='PUT', headers=headers) + data = { 'account': self._find_account_id(), 'container': container, @@ -173,7 +195,8 @@ class APIv1(api.BaseAPI): 'object_count': response.headers.get( 'x-container-object-count' ), - 'bytes_used': response.headers.get('x-container-bytes-used') + 'bytes_used': response.headers.get('x-container-bytes-used'), + 'storage_policy': response.headers.get('x-storage-policy'), } if 'x-container-read' in response.headers: |
