From e569d99077f87cb7d1b336b5b8bf933e37f46759 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Wed, 13 Nov 2024 08:48:24 +0300 Subject: [PATCH] Add generator playground --- ftd_playground/connection.py | 26 ++++++++++++++++++++++++++ sandbox.py | 10 ++++++++++ 2 files changed, 36 insertions(+) create mode 100644 ftd_playground/connection.py create mode 100644 sandbox.py diff --git a/ftd_playground/connection.py b/ftd_playground/connection.py new file mode 100644 index 0000000..9b8d4c3 --- /dev/null +++ b/ftd_playground/connection.py @@ -0,0 +1,26 @@ +from typing import Dict + +from netmiko import (ConnectHandler, NetmikoBaseException, + NetMikoTimeoutException) +from netmiko.cisco import CiscoFtdSSH + + +def prepare_cisco_ftd_session(connect_data: Dict): + try: + ftd_session = CiscoFtdSSH(**connect_data) + return ftd_session + except NetMikoTimeoutException: + raise ValueError() + + +if __name__ == "__main__": + request_data = { + "host": "172.31.142.223", + "username": "admin", + "password": "T15462&93016n.", + "port": 22, + } + session = prepare_cisco_ftd_session(request_data) + session.serial_login() + result = session.send_command("show version") + print(result) diff --git a/sandbox.py b/sandbox.py new file mode 100644 index 0000000..f087dc8 --- /dev/null +++ b/sandbox.py @@ -0,0 +1,10 @@ +def createGenerator() : + mylist = range(3) + for i in mylist : + yield i*i + +gen = createGenerator() +print(gen) + +for i in gen: + print(i) \ No newline at end of file