Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Course:

https://pynet.twb-tech.com/blog/automation/netmiko.html




#With the dictionary


Code Block
titleBasic Call
#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
titleconnect

# 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)