Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Cisco IOS commands show vlan and show cdp neighbor have a lot of header and trailer information. See show vlan brief for vlan expectations
The Cisco IOS commands show vlan and show cdp neighbor have a lot of header and trailer information. See show vlan brief for vlan expectations You will create two programs. one to execute commands and print the output login to a device retrieve the output of show vlan, and show cdp neighbors pass output of commands to functions print the function returns the other will have only the two functions removeheader removetrailer Both functions will require two arguments. String data from show command Delimiter Each function will need to perform the following Split the string to a list, using newline character as delimiter. Find the index position of the delimiter Slice the list based on the delimiters index position Convert the list back to the string using code similar to this: Mystring For x in list: Mystring n x #mystring mystring n x Return the list to the original function call 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
The Cisco IOS commands show vlan and show cdp neighbor have a lot of header and trailer information. See show vlan brief for vlan expectations
You will create two programs.
one to execute commands and print the output
login to a device
retrieve the output of show vlan, and show cdp neighbors
pass output of commands to functions
print the function returns
the other will have only the two functions
removeheader
removetrailer
Both functions will require two arguments.
String data from show command
Delimiter
Each function will need to perform the following
Split the string to a list, using newline character
as delimiter.
Find the index position of the delimiter
Slice the list based on the delimiters index position
Convert the list back to the string using code similar to this:
Mystring
For x in list:
Mystring n x
#mystring mystring n x
Return the list to the original function call
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