Monday, July 18, 2016

My Third Step towards Automation: How to map Junos Commands to PyEZ RPC


In JUNOS, it’s very easy to find any RPC equivalent of the existing command by running “show route | display xml rpc”. This helps to find what is equivalent RPC command of show route as per below output.

get-route-information

It’s very difficult to find every time on cli what is equivalent of RPC of any Junos command. So we can leverage PyEZ to find the same and in the upcoming posts, you can check how it can be leverage to pass the different values directly in the RPC calls. In PyEZ we can call display_xml_rpc library to get the information of any RPC equivalent Junos Command.

from jnpr.junos import Device
from jnpr.junos.exception import ConnectError
dev = Device(host='192.168.1.1', user='lab', passwd=’lab')
try:
dev.open()
except ConnectError as err:
print "Cannot connect to device: {0}".format(err)
sys.exit(1)
print dev.display_xml_rpc('show route',format='text')
print dev.display_xml_rpc('show interface',format='text')
print dev.display_xml_rpc('show ospf neighbor',format='text')
dev.close()
The output of above file is given below:-
C:\Python27>python.exe testing\connect_device_rpc.py
RPC of show route is:
get-route-information

RPC of show interface is:
get-interface-information

RPC of show ospf neighbor is:
get-ospf-neighbor-information

People who read this post also read :



5 comments:

Mark Winstanley said...

This web site is actually terrific and wonderful data perhaps there's and searching thus charming... I look and feel smart to usually be here... Keep sharing kickshaws with buddies.. Thanks meant for sharing...

Structured Cabling

Mark Winstanley said...

This web site is actually terrific and wonderful data perhaps there's and searching thus charming... I look and feel smart to usually be here... Keep sharing kickshaws with buddies.. Thanks meant for sharing...

Structured Cabling

Jeffy said...


Superb explanation & it's too clear to understand the concept as well, keep sharing admin with some updated information with right examples.Keep update more posts.

SEO Training in Chennai

Teena said...

I keep on reading your blog post.. This was still amazing. Thanks a lot for sharing this unique informative post with us.. I really enjoyed by reading your blog post

Seo Training in Chennai

Sathya G said...

Thank you for sharing such a nice and interesting blog with us. i have seen that all will say the same thing repeatedly. But in your blog, I had a chance to get some useful and unique information. I would like to suggest your blog in my dude circle. please keep on updates. hope it might be much useful for us. keep on updating...
Software Testing Training