File tree Expand file tree Collapse file tree
doc/source/command-objects Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -19,6 +19,16 @@ Set account properties
1919
2020 Set a property on this account (repeat option to set multiple properties)
2121
22+ account show
23+ ------------
24+
25+ Display account details
26+
27+ .. program :: account show
28+ .. code :: bash
29+
30+ os account show
31+
2232 account unset
2333-------------
2434
Original file line number Diff line number Diff line change @@ -411,6 +411,23 @@ def account_set(
411411 # registered in the catalog
412412 self .create ("" , headers = headers )
413413
414+ def account_show (self ):
415+ """Show account details"""
416+
417+ # NOTE(stevemar): Just a HEAD request to the endpoint already in the
418+ # catalog should be enough.
419+ response = self ._request ("HEAD" , "" )
420+ data = {}
421+ for k , v in response .headers .iteritems ():
422+ data [k ] = v
423+ # Map containers, bytes and objects a bit nicer
424+ data ['Containers' ] = data .pop ('x-account-container-count' , None )
425+ data ['Objects' ] = data .pop ('x-account-object-count' , None )
426+ data ['Bytes' ] = data .pop ('x-account-bytes-used' , None )
427+ # Add in Account info too
428+ data ['Account' ] = self ._find_account_id ()
429+ return data
430+
414431 def account_unset (
415432 self ,
416433 properties ,
@@ -433,3 +450,7 @@ def account_unset(
433450
434451 if headers :
435452 self .create ("" , headers = headers )
453+
454+ def _find_account_id (self ):
455+ url_parts = urlparse (self .endpoint )
456+ return url_parts .path .split ('/' )[- 1 ]
Original file line number Diff line number Diff line change 1313
1414"""Account v1 action implementations"""
1515
16-
1716import logging
1817
1918from cliff import command
19+ from cliff import show
20+ import six
2021
2122from openstackclient .common import parseractions
2223from openstackclient .common import utils
@@ -46,6 +47,17 @@ def take_action(self, parsed_args):
4647 )
4748
4849
50+ class ShowAccount (show .ShowOne ):
51+ """Display account details"""
52+
53+ log = logging .getLogger (__name__ + '.ShowAccount' )
54+
55+ @utils .log_method (log )
56+ def take_action (self , parsed_args ):
57+ data = self .app .client_manager .object_store .account_show ()
58+ return zip (* sorted (six .iteritems (data )))
59+
60+
4961class UnsetAccount (command .Command ):
5062 """Unset account properties"""
5163
Original file line number Diff line number Diff line change @@ -332,6 +332,7 @@ openstack.network.v2 =
332332
333333openstack.object_store.v1 =
334334 account_set = openstackclient.object.v1.account:SetAccount
335+ account_show = openstackclient.object.v1.account:ShowAccount
335336 account_unset = openstackclient.object.v1.account:UnsetAccount
336337 container_create = openstackclient.object.v1.container:CreateContainer
337338 container_delete = openstackclient.object.v1.container:DeleteContainer
You can’t perform that action at this time.
0 commit comments