Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
Forked from jeffbrl/config.py
Created February 14, 2017 03:37
Show Gist options
  • Save dirkakrid/e738737da9e2c88741e2e2d0947657cb to your computer and use it in GitHub Desktop.
Save dirkakrid/e738737da9e2c88741e2e2d0947657cb 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