Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started