def setUpClass(cls): users = {'testadmin': 'x'} MockSSH.startThreadedServer(commands, prompt="hostname>", interface="localhost", port=9999, **users)
def setUpClass(cls): users = {'testadmin': 'x'} MockSSH.startThreadedServer( commands, prompt="[root@hostname:Active] testadmin # ", interface="localhost", port=1025, **users)
def setUpClass(cls): users = {'testadmin': 'x'} cls.keypath = tempfile.mkdtemp() MockSSH.startThreadedServer(commands, prompt="hostname>", keypath=cls.keypath, interface="localhost", port=9999, **users)
def setUpClass(cls): users = {'testadmin': 'x'} cls.keypath = tempfile.mkdtemp() MockSSH.startThreadedServer( commands, prompt="[root@hostname:Active] testadmin # ", keypath=cls.keypath, interface="localhost", port=1025, **users)
def setUpClass(cls): # # command: pwd # def pwd_command_success(instance): instance.writeln("[OK]") def pwd_command_failure(instance): instance.writeln("MockSSH: Supported usage: pwd") command_pwd = MockSSH.ArgumentValidatingCommand( 'pwd', [pwd_command_success], [pwd_command_failure], *[]) # # command: ls # def ls_command_success(instance): instance.writeln("[OK]") def ls_command_failure(instance): instance.writeln("MockSSH: Supported usage: ls l") command_ls = MockSSH.ArgumentValidatingCommand('ls', [ls_command_success], [ls_command_failure], *["l"]) # # command: date # def date_command_success(instance): instance.writeln("[OK]") def date_command_failure(instance): instance.writeln("MockSSH: Supported usage: date") command_date = MockSSH.ArgumentValidatingCommand( 'date', [date_command_success], [date_command_failure], *[]) commands = [command_pwd, command_ls, command_date] users = {'testadmin': 'x'} cls.keypath = tempfile.mkdtemp() MockSSH.startThreadedServer(commands, prompt="hostname>", keypath=cls.keypath, interface="localhost", port=9999, **users)
def start_cisco_mock(initial_prompt='>'): """This is where we define everything that is emulated""" # List of commands to emulate... see definitions above commands = [ command_en, command_enable, command_term_len, command_sh_ip_int_brief, command_sh_ver, command_conf, command_username, command_wr, command_quit, command_end, command_exit, ] users = {'admin': 'cisco'} MockSSH.startThreadedServer(commands, prompt=CRLF+"{0}{1}".format(HOSTNAME, initial_prompt), interface="localhost", port=2222, **users)