In the previous interactive prompt, we already saw that when the device connects, the object automatically retrieves a few facts about the device. In our first example, junos_pyez_1.py, we were connecting to the device and executing an RPC call for show interface em1:
#!/usr/bin/env python3 from jnpr.junos import Device import xml.etree.ElementTree as ET import pprint dev = Device(host='192.168.24.252', user='juniper', passwd='juniper!') try: dev.open() except Exception as err: print(err) sys.exit(1) result = dev.rpc.get_interface_information(interface_name='em1', terse=True) pprint.pprint(ET.tostring(result)) dev.close()
The device class has an rpc property that includes all operational commands. This is pretty awesome because ...