GeezerVison is showing github.com — fix cloud-tool to list all the available apis · folkcode/cloudstack@b9a2423
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: cloud-cli/cloudapis/cloud.py +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -111,3 +111,5 @@ def %s(%s): |
111 | 111 | implementor = CloudAPI |
112 | 112 |
|
113 | 113 | del name,meth,describe,load_dynamic_methods |
| 114 | + |
| 115 | + |
Collapse file
Copy file name to clipboardExpand all lines: cloud-cli/cloudtool/__init__.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,7 +20,7 @@ def main(argv=None): |
20 | 20 | api = __import__("cloudapis") |
21 | 21 | apis = getattr(api, "implementor") |
22 | 22 | if len(prelim_args) == 0: |
23 | | - parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list())) |
| 23 | + parser.error("you need to specify an API as the first argument\n\nSupported APIs:\n" + "\n".join(utils.get_api_list(apis))) |
24 | 24 | elif len(prelim_args) == 1: |
25 | 25 | commandlist = utils.get_command_list(apis) |
26 | 26 | 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)) |
|
Collapse file
Copy file name to clipboardExpand all lines: cloud-cli/cloudtool/utils.py +7-8Lines changed: 7 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -165,14 +165,13 @@ def lookup_command_in_api(api,command_name): |
165 | 165 | command = getattr(api,command_name.replace("-","_"),None) |
166 | 166 | return command |
167 | 167 |
|
168 | | -def get_api_list(): |
169 | | - apilist = [] |
170 | | - for api in apis.get_all_apis(): |
171 | | - api_module = api |
172 | | - api_name = api.__name__.split(".")[-1] |
173 | | - if not api_name.startswith("_") and hasattr(api_module,'__doc__'): |
174 | | - apilist.append( " %20s %s"%(api_name.replace("_",'-'),api_module.__doc__) ) |
175 | | - return apilist |
| 168 | +def get_api_list(api): |
| 169 | + apilist = [] |
| 170 | + for cmd_name in dir(api): |
| 171 | + cmd = getattr(api,cmd_name) |
| 172 | + if callable(cmd) and not cmd_name.startswith("_"): |
| 173 | + apilist.append(cmd_name) |
| 174 | + return apilist |
176 | 175 |
|
177 | 176 | def get_command_list(api): |
178 | 177 | cmds = [] |
|