Question: 1 . Create a list, called port _ list, It shall include all ports between 2 2 0 5 - 2 2 1 4 .
Create a list, called portlist, It shall include all ports between
a Create a loop that iterates through each list element
i Use the function len to stop the loop
ii Print port list position # and port number of each list item
Example..... Port
Create a program that reads from a list of port numbers to login to network devices.
a Create a list called portlist that contains ports
b Create a for loop that uses the len of portlist as stop point
i Loop shall connect to each device in portlist.
c Create s dictionary named cisco that contains
i Devicetype
ii Ip
iii. Username
iv Password
v Port from portlist
d Connect to each device in portlist
Conditionals
a If statements with the less than operator to overwrite the device type.
b Use an if statement to prevent attempts at port
i Use the continue statement
Exception Handling
a Import Netmiko authenticaton and timeout exceptions
i Dont forget the general exception Clause
b Use a try and exept block to catch exceptions so loop continues to operate
i Use a print statement to notify user that an error has occurred.
Testing
a Add a conditional that sets the password to CISCO for port
b Add an invalid port to the list, somewhere before the last element.
device login script
devicelogin.py
a basic program to create an initial login to a cisco device
from netmiko import ConnectHandler
device
'devicetype': 'vyos',
ip:
'port':
'username': 'itsc
'password': itsc',
#create SSH socket to connect to device using the data in the library 'cisco'
netconnect ConnectHandlerdevice
promptnetconnect.findprompt
printprompt
Device NamePort Vendor DeviceTypeType Model Username Password Inside IP Address
DLLSCOR VYOS vyos Router itscitsc
DLLSCOR VYOS vyos Router itscitsc
DLLSDIS VYOS vyos Router itscitsc
DLLSDIS VYOS vyos Router itscitsc
DLLSACC Extreme NetworksextremeexosL Switch XSQ itscitsc
DLLSACC Extreme NetworksextremeexosL Switch XSQ itscitsc
DLLSACC Extreme NetworksextremeexosL Switch XSQ itscitsc
FTWCOR MikroTik mikrotikrouterosRouter itscthitsc
FTWCOR MikroTik mikrotikrouterosRouter itscthitsc
FTWDIS MikroTik mikrotikrouterosRouter itscthitsc
FTWDIS MikroTik mikrotikrouterosRouter itscthitsc
FTWACC Extreme NetworksextremeexosL Switch XSQ itscitsc
FTWACC Extreme NetworksextremeexosL Switch XSQ itscitsc
FTWACC Extreme NetworksextremeexosL Switch XSQ itscitsc
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
