rtr2 = Router('isr4221', '16.9.5', '10.10.10.5')
sw1 = Switch('Cat9300', '16.9.5', '10.10.10.8')
print('Rtr1\n', rtr1.getdesc(), '\n', sep='')
print('Rtr2\n', rtr2.getdesc(), '\n', sep='')
print('Sw1\n', sw1.getdesc(), '\n', sep='')
When you execute this program, you get the output
shown in Example 4-5. If you compare these results with
the results shown in Example 4-3, you see that they are
exactly the same. Therefore, the device module is just
Python code that is stored in another file but used in
your program.
Example 4-5 Code Results of device.py Import as a
Module
Click here to view code image
Rtr1
Router Model :iosV
Software Version :15.6.7
Router Management Address:10.10.10.1
Rtr2
Router Model :isr4221
Software Version :16.9.5
Router Management Address:10.10.10.5
Sw1
Switch Model :Cat9300
Software Version :16.9.5
Router Management Address:10.10.10.8
Useful Python Modules for Cisco Infrastructure
This chapter cannot cover every single module that you
might find valuable when writing Python code to interact
with Cisco infrastructure. As you become more familiar
with Python, you will come to love and trust a wide range
of standard library and third-party modules. The
following list includes many that are widely used to