diff options
| author | Simon Merrick <simonmerrick@catalyst.net.nz> | 2020-02-18 12:48:02 +1300 |
|---|---|---|
| committer | Simon Merrick <simonmerrick@catalyst.net.nz> | 2020-02-19 10:08:48 +1300 |
| commit | d6022f96dfd608b83a4ff41483336f024aeacb16 (patch) | |
| tree | 6725370f16ff067e6dc7bbbfbb6aa2bfd683e778 /openstackclient/api | |
| parent | e07324e30fbb24e89fd63d1c5a5fe485f693a45c (diff) | |
| download | python-openstackclient-d6022f96dfd608b83a4ff41483336f024aeacb16.tar.gz | |
Add storage policy option to create container command
+ Add CLI option to specify swift storage policy
+ Add CLI flag to specify container uses public read ACLS
+ Show storage policy in container show data
Change-Id: I08ffa0d98bd39d467aa415771675f59bd77768ff
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: |
