@ -1930,7 +1930,7 @@ class DecortController(object):
return
def account_find ( self , account_name , account_id = 0 ,
fail_if_not_found= False ) :
resource_consumption= False , fail_if_not_found= False ) :
""" Find cloud account specified by the name and return facts about the account. Knowing account is
required for certain cloud resource management tasks ( e . g . creating new RG ) .
@ -1995,6 +1995,16 @@ class DecortController(object):
account_details [ ' updatedTime ' ]
)
if resource_consumption :
resource_consumption = self . account_resource_consumption (
account_id = account_details [ ' id ' ] ,
fail_if_not_found = True
)
account_details [ ' resource_consumed ' ] = \
resource_consumption [ ' Consumed ' ]
account_details [ ' resource_reserved ' ] = \
resource_consumption [ ' Reserved ' ]
return account_details [ ' id ' ] , account_details
else :
if fail_if_not_found :
@ -2005,6 +2015,25 @@ class DecortController(object):
else :
return 0 , None
def account_resource_consumption ( self , account_id : int ,
fail_if_not_found = False ) - > None | dict :
self . result [ ' waypoints ' ] + = f ' -> account_resource_consumption '
api_resp = self . decort_api_call (
arg_req_function = requests . post ,
arg_api_name = ' /restmachine/cloudapi/account/getResourceConsumption ' ,
arg_params = { ' accountId ' : account_id } ,
not_fail_codes = [ 404 ]
)
if api_resp . status_code == 200 :
return api_resp . json ( )
else :
if fail_if_not_found :
self . result [ ' msg ' ] = ( " Current user does not have access to "
" the requested account or non-existent "
" account specified. " )
self . amodule . fail_json ( * * self . result )
###################################
# GPU resource manipulation methods
###################################