From 6fe015fda0a71f2f822b3140663ee61c345c575a Mon Sep 17 00:00:00 2001 From: wertha Date: Fri, 26 May 2023 04:19:20 -0700 Subject: [PATCH] Add telnet and http services when running from cmd --- fake_switches/cmd/main.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/fake_switches/cmd/main.py b/fake_switches/cmd/main.py index dc05e0b9..96d44659 100644 --- a/fake_switches/cmd/main.py +++ b/fake_switches/cmd/main.py @@ -3,7 +3,9 @@ from fake_switches import switch_factory +from fake_switches.transports.http_service import SwitchHttpService from fake_switches.transports.ssh_service import SwitchSshService +from fake_switches.transports.telnet_service import SwitchTelnetService from twisted.internet import reactor @@ -31,6 +33,26 @@ def main(): factory = switch_factory.SwitchFactory() switch_core = factory.get(args.model, args.hostname, args.password) + if args.model == "arista_generic": + http_service = SwitchHttpService( + ip=args.listen_host, + port=80, + switch_core=switch_core, + users={args.username: args.password}) + http_service.hook_to_reactor(reactor) + + if args.model in ['cisco_generic', + 'cisco_2960_24TT_L', + 'cisco_2960_48TT_L', + 'dell_generic', + 'dell10g_generic']: + telnet_service = SwitchTelnetService( + ip=args.listen_host, + port=args.listen_port+1, + switch_core=switch_core, + users={args.username: args.password}) + telnet_service.hook_to_reactor(reactor) + ssh_service = SwitchSshService( ip=args.listen_host, port=args.listen_port,