diff --git a/reddwarfclient/accounts.py b/reddwarfclient/accounts.py index 183330e5..43e91358 100644 --- a/reddwarfclient/accounts.py +++ b/reddwarfclient/accounts.py @@ -14,6 +14,7 @@ # under the License. from reddwarfclient import base +from reddwarfclient.common import check_for_exceptions class Account(base.Resource): @@ -37,6 +38,16 @@ class Accounts(base.ManagerWithFind): raise Exception("Call to " + url + " did not return a body.") return self.resource_class(self, body[response_key]) + def index(self): + """Get a list of all accounts with non-deleted instances""" + + url = "/mgmt/accounts" + resp, body = self.api.client.get(url) + check_for_exceptions(resp, body) + if not body: + raise Exception("Call to " + url + " did not return a body.") + return base.Resource(self, body) + def show(self, account): """ Get details of one account. diff --git a/reddwarfclient/mcli.py b/reddwarfclient/mcli.py index 8f40dcf0..394d1432 100644 --- a/reddwarfclient/mcli.py +++ b/reddwarfclient/mcli.py @@ -90,6 +90,14 @@ class AccountCommands(object): def __init__(self): pass + def list(self): + """List all accounts with non-deleted instances""" + dbaas = common.get_client() + try: + _pretty_print(dbaas.accounts.index()._info) + except: + print sys.exc_info()[1] + def get(self, acct): """List details for the account provided""" dbaas = common.get_client()