diff options
| author | Steve Martinelli <stevemar@ca.ibm.com> | 2015-09-10 16:06:32 -0500 |
|---|---|---|
| committer | Lin Hua Cheng <os.lcheng@gmail.com> | 2015-10-02 01:20:06 +0000 |
| commit | 4733fd0d3cd328a8abbd62cbfabd973b0986c58c (patch) | |
| tree | 26a504a93cc3d587bc49e03d2256a6a7ce8dbb81 /openstackclient/api | |
| parent | a4483a05137bbd3ed416b6a61687315095ccced7 (diff) | |
| download | python-openstackclient-4733fd0d3cd328a8abbd62cbfabd973b0986c58c.tar.gz | |
Add support for showing account details
add the command `openstack account show` that lists details
about the object store account that the user authenticated
against.
Partial-Bug: #1501943
Change-Id: I1246dafee812b63a41d43be4e3598224364a2c11
Diffstat (limited to 'openstackclient/api')
| -rw-r--r-- | openstackclient/api/object_store_v1.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/openstackclient/api/object_store_v1.py b/openstackclient/api/object_store_v1.py index c817b650..afc5b4c1 100644 --- a/openstackclient/api/object_store_v1.py +++ b/openstackclient/api/object_store_v1.py @@ -411,6 +411,23 @@ class APIv1(api.BaseAPI): # registered in the catalog self.create("", headers=headers) + def account_show(self): + """Show account details""" + + # NOTE(stevemar): Just a HEAD request to the endpoint already in the + # catalog should be enough. + response = self._request("HEAD", "") + data = {} + for k, v in response.headers.iteritems(): + data[k] = v + # Map containers, bytes and objects a bit nicer + data['Containers'] = data.pop('x-account-container-count', None) + data['Objects'] = data.pop('x-account-object-count', None) + data['Bytes'] = data.pop('x-account-bytes-used', None) + # Add in Account info too + data['Account'] = self._find_account_id() + return data + def account_unset( self, properties, @@ -433,3 +450,7 @@ class APIv1(api.BaseAPI): if headers: self.create("", headers=headers) + + def _find_account_id(self): + url_parts = urlparse(self.endpoint) + return url_parts.path.split('/')[-1] |
