Add generator playground
This commit is contained in:
parent
cd90541216
commit
e569d99077
2 changed files with 36 additions and 0 deletions
26
ftd_playground/connection.py
Normal file
26
ftd_playground/connection.py
Normal file
|
@ -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)
|
10
sandbox.py
Normal file
10
sandbox.py
Normal file
|
@ -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)
|
Loading…
Reference in a new issue