@@ -222,12 +222,11 @@ def process_json(response):
222222 response = json .loads (str (response ))
223223 except ValueError , e :
224224 pass
225-
226- if response is None :
227- return {'error' : 'Error: json error' }
228225 return response
229226
230227 response = process_json (response )
228+ if response is None :
229+ return
231230
232231 isAsync = isAsync and (self .asyncblock == "true" )
233232 if isAsync and 'jobid' in response [response .keys ()[0 ]]:
@@ -260,7 +259,7 @@ def get_api_module(self, api_name, api_class_strs=[]):
260259 api_mod = __import__ ("marvin.cloudstackAPI.%s" % api_name ,
261260 globals (), locals (), api_class_strs , - 1 )
262261 except ImportError , e :
263- self .print_shell ("Error: API %s not found!" % e )
262+ self .print_shell ("Error: API not found" , e )
264263 return None
265264 return api_mod
266265
@@ -281,23 +280,21 @@ def default(self, args):
281280 x .partition ("=" )[2 ]],
282281 args [1 :])[x ] for x in range (len (args ) - 1 ))
283282
283+ api_cmd_str = "%sCmd" % api_name
284+ api_mod = self .get_api_module (api_name , [api_cmd_str ])
285+ if api_mod is None :
286+ return
287+
284288 try :
285- api_cmd_str = "%sCmd" % api_name
286- api_rsp_str = "%sResponse" % api_name
287- api_mod = self .get_api_module (api_name , [api_cmd_str , api_rsp_str ])
288289 api_cmd = getattr (api_mod , api_cmd_str )
289- api_rsp = getattr (api_mod , api_rsp_str )
290290 except AttributeError , e :
291- self .print_shell ("Error: API %s not found!" % e )
291+ self .print_shell ("Error: API attribute %s not found!" % e )
292292 return
293293
294294 for attribute in args_dict .keys ():
295- # if attribute in args_dict:
296295 setattr (api_cmd , attribute , args_dict [attribute ])
297296
298297 command = api_cmd ()
299- response = api_rsp ()
300-
301298 missing_args = list (sets .Set (command .required ).difference (
302299 sets .Set (args_dict .keys ())))
303300
@@ -322,9 +319,11 @@ def cache_verb_miss(self, verb):
322319 completions_found = filter (lambda x : x .startswith (verb ), completions )
323320 self .cache_verbs [verb ] = {}
324321 for api_name in completions_found :
322+ api_cmd_str = "%sCmd" % api_name
323+ api_mod = self .get_api_module (api_name , [api_cmd_str ])
324+ if api_mod is None :
325+ continue
325326 try :
326- api_cmd_str = "%sCmd" % api_name
327- api_mod = self .get_api_module (api_name , [api_cmd_str ])
328327 api_cmd = getattr (api_mod , api_cmd_str )()
329328 required = api_cmd .required
330329 doc = api_mod .__doc__
@@ -474,11 +473,12 @@ def do_EOF(self, args):
474473def main ():
475474 # Add verbs in grammar
476475 grammar = ['create' , 'list' , 'delete' , 'update' ,
477- 'enable' , 'disable' , 'add' , 'remove' , 'attach' , 'detach' ,
476+ 'enable' , 'activate' , 'disable' , 'add' , 'remove' ,
477+ 'attach' , 'detach' , 'associate' , 'generate' , 'ldap' ,
478478 'assign' , 'authorize' , 'change' , 'register' , 'configure' ,
479479 'start' , 'restart' , 'reboot' , 'stop' , 'reconnect' ,
480- 'cancel' , 'destroy' , 'revoke' ,
481- 'copy' , 'extract' , 'migrate' , 'restore' ,
480+ 'cancel' , 'destroy' , 'revoke' , 'mark' , 'reset' ,
481+ 'copy' , 'extract' , 'migrate' , 'restore' , 'suspend' ,
482482 'get' , 'query' , 'prepare' , 'deploy' , 'upload' ]
483483
484484 # Create handlers on the fly using closures
@@ -501,7 +501,7 @@ def grammar_closure(self, args):
501501 except KeyError , e :
502502 self .print_shell ("Error: no such command on %s" % rule )
503503 return
504- if '--help' in args :
504+ if ' --help' in args or ' -h ' in args :
505505 self .print_shell (res [2 ])
506506 return
507507 self .default (res [0 ] + " " + args_partition [2 ])
0 commit comments