Course:
https://pynet.twb-tech.com/blog/automation/netmiko.html
|
|
---|
#With the dictionary |
Code Block |
---|
| #Define a dictionary
juniper_junos_dict = {
'device_type': 'juniper',
'ip': "172.30.95.177",
'username': "Netbox",
'password': "Netbox"
}
# connect to the Device
net_connect = ConnectHandler(**juniper_junos, global_delay_factor=2)
#run the command and write to file
cmd_output = net_connect.send_command('show chassis hardware | display xml ')
#print the command's output
print(cmd_output) |
|
#Without the dictionary |
Code Block |
---|
|
# connect to the Device
net_connect = ConnectHandler(device_type= 'juniper',host= ip_addr,username= "Netbox",password= "Netbox")
#run the command and write to file
cmd_output = net_connect.send_command('show chassis hardware | display xml ')
#print the command's output
print(cmd_output) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|