diff options
| author | Dean Troyer <dtroyer@gmail.com> | 2013-08-30 17:55:37 -0500 |
|---|---|---|
| committer | Dean Troyer <dtroyer@gmail.com> | 2013-09-26 13:34:11 -0500 |
| commit | ad59b03be6af9da31230689af268139b12b548e7 (patch) | |
| tree | 0394d365ab2b1d847ae20f46b0c208a71e5dd9a3 /openstackclient/object/v1/lib/container.py | |
| parent | 74f4e3138996e258d4bdce1a162a5dade62a0c15 (diff) | |
| download | python-openstackclient-ad59b03be6af9da31230689af268139b12b548e7.tar.gz | |
Add object-store show commands
* Add lib.container.show_container() and lib.object.show_object()
* Add container and object show commands
Change-Id: I963d664c55b59739453345f0f353aa2eaf1bf70e
Diffstat (limited to 'openstackclient/object/v1/lib/container.py')
| -rw-r--r-- | openstackclient/object/v1/lib/container.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/openstackclient/object/v1/lib/container.py b/openstackclient/object/v1/lib/container.py index f30533c8..5103d9d4 100644 --- a/openstackclient/object/v1/lib/container.py +++ b/openstackclient/object/v1/lib/container.py @@ -16,6 +16,11 @@ """Object v1 API library""" +try: + from urllib.parse import urlparse +except ImportError: + from urlparse import urlparse + def list_containers( api, @@ -75,3 +80,34 @@ def list_containers( url = "%s?%s" % (object_url, query) response = api.request('GET', url) return response.json() + + +def show_container( + api, + url, + container, +): + """Get container details + + :param api: a restapi object + :param url: endpoint + :param container: name of container to show + :returns: dict of returned headers + """ + + object_url = "%s/%s" % (url, container) + url_parts = urlparse(url) + response = api.request('HEAD', object_url) + data = { + 'account': url_parts.path.split('/')[-1], + 'container': container, + } + data['object_count'] = response.headers.get( + 'x-container-object-count', None) + data['bytes_used'] = response.headers.get('x-container-bytes-used', None) + data['read_acl'] = response.headers.get('x-container-read', None) + data['write_acl'] = response.headers.get('x-container-write', None) + data['sync_to'] = response.headers.get('x-container-sync-to', None) + data['sync_key'] = response.headers.get('x-container-sync-key', None) + + return data |
