def __invokeLoginExec(self): """Here we check for the password before the user enters exec prompt""" incorrect_attempts = 0 while True: if incorrect_attempts > 2: break try: p = getpass.getpass("Enter password for privilege execution mode:") if lib.essentials.enterExecutiveMode(p) == 0: return vps_cli.cli_runner("enable") else: incorrect_attempts = incorrect_attempts + 1 print "Permission denied, please try again." except: # print "\n" break
def __invokeLoginExec(self): '''Here we check for the password before the user enters exec prompt''' incorrect_attempts = 0 while (True): if incorrect_attempts > 2: break try: p = getpass.getpass( 'Enter password for privilege execution mode:') if lib.essentials.enterExecutiveMode(p) == 0: return vps_cli.cli_runner('enable') else: incorrect_attempts = incorrect_attempts + 1 print 'Permission denied, please try again.' except: #print "\n" break
def __invokeDisable(self): '''This will bring the prompt back to standard mode''' vps_cli.set_current_prompt(lib.constants._VFM_STAN) new_prompt = lib.constants._VFM_STAN vps_cli.cli_runner('disable')
def __invokeConfig(self, modifier, cmd, command_name, args): '''Calls the correct prompt function''' if vps_cli.get_current_prompt() == lib.constants._VFM_STAN \ or vps_cli.get_current_prompt() == None: print NameError("'%s' command can't be invoked in standard mode. " % \ (args)) return # # FIXME: Should check if the modifier is "add" then # args should contain an unique <object> # if modifier not in command_ref.COMMAND_MODIFIER: raise NameError("'%s' command can't be invoked by the action %s" % \ (cmd, modifier)) #else : # print 'Call the appropriate module to handle the modifier' # This is done due to changes made in the design. # FIXME: Make some changes according to the final design. # if vps_cli.check_mode_change(cmd) != 0: raise NameError("Incorrect command to change mode \ Usage : <mode> <object>") #print modifier , cmd , command_name , args cmd = command_name args_len = len(args) if cmd == "": return -1 if cmd != "": tokens = cmd.split() #if args_len == 0 and tokens[1] != "": # vps_cli.cli_runner(tokens[1]) if args_len > 0: if tokens[0] != 'configure': print 'This is modifier ', args else: if args_len < 3: command_extension = tokens[1] global vps_current_module vps_current_module = args[1] vps_cli.cli_runner(command_extension) elif args_len == 3: if args[2] == 'configure': print lib.errorhandler.InvalidArgumentCount() else: print 'This is modifier ', args elif args_len == 4: if args[2] == 'configure' and args[3] != "": command_extension = tokens[1] + ' ' + args[ 1] + ' ' + args[3] vps_cli.cli_runner(command_extension) elif args_len > 4: print args return 0
def __invokeDisable(self): """This will bring the prompt back to standard mode""" vps_cli.set_current_prompt(lib.constants._VFM_STAN) new_prompt = lib.constants._VFM_STAN vps_cli.cli_runner("disable")
def __invokeConfig(self, modifier, cmd, command_name, args): """Calls the correct prompt function""" if vps_cli.get_current_prompt() == lib.constants._VFM_STAN or vps_cli.get_current_prompt() == None: print NameError("'%s' command can't be invoked in standard mode. " % (args)) return # # FIXME: Should check if the modifier is "add" then # args should contain an unique <object> # if modifier not in command_ref.COMMAND_MODIFIER: raise NameError("'%s' command can't be invoked by the action %s" % (cmd, modifier)) # else : # print 'Call the appropriate module to handle the modifier' # This is done due to changes made in the design. # FIXME: Make some changes according to the final design. # if vps_cli.check_mode_change(cmd) != 0: raise NameError( "Incorrect command to change mode \ Usage : <mode> <object>" ) # print modifier , cmd , command_name , args cmd = command_name args_len = len(args) if cmd == "": return -1 if cmd != "": tokens = cmd.split() # if args_len == 0 and tokens[1] != "": # vps_cli.cli_runner(tokens[1]) if args_len > 0: if tokens[0] != "configure": print "This is modifier ", args else: if args_len < 3: command_extension = tokens[1] global vps_current_module vps_current_module = args[1] vps_cli.cli_runner(command_extension) elif args_len == 3: if args[2] == "configure": print lib.errorhandler.InvalidArgumentCount() else: print "This is modifier ", args elif args_len == 4: if args[2] == "configure" and args[3] != "": command_extension = tokens[1] + " " + args[1] + " " + args[3] vps_cli.cli_runner(command_extension) elif args_len > 4: print args return 0