mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
fix cloud-tool to list all the available apis
This commit is contained in:
parent
3f4feaa436
commit
b9a242332b
@ -111,3 +111,5 @@ for name,meth in load_dynamic_methods(): setattr(CloudAPI,name,meth)
|
|||||||
implementor = CloudAPI
|
implementor = CloudAPI
|
||||||
|
|
||||||
del name,meth,describe,load_dynamic_methods
|
del name,meth,describe,load_dynamic_methods
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ def main(argv=None):
|
|||||||
api = __import__("cloudapis")
|
api = __import__("cloudapis")
|
||||||
apis = getattr(api, "implementor")
|
apis = getattr(api, "implementor")
|
||||||
if len(prelim_args) == 0:
|
if len(prelim_args) == 0:
|
||||||
parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list()))
|
parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list(apis)))
|
||||||
elif len(prelim_args) == 1:
|
elif len(prelim_args) == 1:
|
||||||
commandlist = utils.get_command_list(apis)
|
commandlist = utils.get_command_list(apis)
|
||||||
parser.error("you need to specify a command name as the second argument\n\nCommands supported by the %s API:\n"%prelim_args[0] + "\n".join(commandlist))
|
parser.error("you need to specify a command name as the second argument\n\nCommands supported by the %s API:\n"%prelim_args[0] + "\n".join(commandlist))
|
||||||
|
|||||||
@ -165,14 +165,13 @@ def lookup_command_in_api(api,command_name):
|
|||||||
command = getattr(api,command_name.replace("-","_"),None)
|
command = getattr(api,command_name.replace("-","_"),None)
|
||||||
return command
|
return command
|
||||||
|
|
||||||
def get_api_list():
|
def get_api_list(api):
|
||||||
apilist = []
|
apilist = []
|
||||||
for api in apis.get_all_apis():
|
for cmd_name in dir(api):
|
||||||
api_module = api
|
cmd = getattr(api,cmd_name)
|
||||||
api_name = api.__name__.split(".")[-1]
|
if callable(cmd) and not cmd_name.startswith("_"):
|
||||||
if not api_name.startswith("_") and hasattr(api_module,'__doc__'):
|
apilist.append(cmd_name)
|
||||||
apilist.append( " %20s %s"%(api_name.replace("_",'-'),api_module.__doc__) )
|
return apilist
|
||||||
return apilist
|
|
||||||
|
|
||||||
def get_command_list(api):
|
def get_command_list(api):
|
||||||
cmds = []
|
cmds = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user