Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Created October 10, 2015 20:11
Show Gist options
  • Save jeffbrl/136fde2840e7915bb3f2 to your computer and use it in GitHub Desktop.
Save jeffbrl/136fde2840e7915bb3f2 to your computer and use it in GitHub Desktop.
Using xpath to parse junos router configuration
from jnpr.junos import Device
from lxml import etree
dev = Device(host='2001:DB8::1', user='jeffl', passwd='pass123')
dev.open()
config = dev.rpc.get_config()
interface_ip = config.xpath("//interface[name='ge-0/0/1']/unit/family/inet/address/name")[0]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment