This repository was archived by the owner on Oct 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Collect commands with Netmiko
Khelil Sator edited this page Nov 19, 2019
·
1 revision
$ python
Python 3.6.8 (default, Oct 9 2019, 14:04:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from netmiko import ConnectHandler
>>> vMX1 = {'device_type': 'juniper_junos', 'host': '100.123.1.0', 'username': 'jcluser', 'password': 'Juniper!1'}
>>> dev = ConnectHandler(**vMX1)
>>> dev.is_alive()
True
>>> dev.device_type
'juniper_junos'
>>> dev.port
22
>>> dev.find_prompt()
'jcluser@vMX1>'
>>> command_output = dev.send_command("show chassis hardware")
>>> print (command_output)
Hardware inventory:
Item Version Part number Serial number Description
Chassis VM5DD38DAF50 VMX
Midplane
Routing Engine 0 RE-VMX
CB 0 VMX SCB
FPC 0 Virtual FPC
CPU Rev. 1.0 RIOT-LITE BUILTIN
MIC 0 Virtual
PIC 0 BUILTIN BUILTIN Virtual
>>> dev.disconnect()
>>> dev.is_alive()
False
>>> exit()
let's run the script collect_commands.py
$ python collect_commands.py
$ ls show*
show chassis hardware.json show chassis hardware.xml show system information.txt
show chassis hardware.txt show system information.json show system information.xml
$ more show\ chassis\ hardware.txt
Hardware inventory:
Item Version Part number Serial number Description
Chassis VM5DD38DAF50 VMX
Midplane
Routing Engine 0 RE-VMX
CB 0 VMX SCB
FPC 0 Virtual FPC
CPU Rev. 1.0 RIOT-LITE BUILTIN
MIC 0 Virtual
PIC 0 BUILTIN BUILTIN Virtual