Skip to content

Instantly share code, notes, and snippets.

@jeffbrl
Created April 24, 2015 18:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffbrl/e628a12c73c9a17d0008 to your computer and use it in GitHub Desktop.
Save jeffbrl/e628a12c73c9a17d0008 to your computer and use it in GitHub Desktop.
Pyez RSVP Table/View
#!/usr/bin/env python
import yaml
from jnpr.junos.factory.factory_loader import FactoryLoader
from jnpr.junos import Device
yml = '''
---
RsvpTable:
rpc: get-rsvp-session-information
item: rsvp-session-data/rsvp-session
key: name
view: RsvpView
RsvpView:
fields:
destination_address: destination-address
source_address: source-address
route_count: route-count
rsb_count: rsb-count
resv_style: resv-style
label_in: label-in
lsp_state: lsp-state
'''
globals().update(FactoryLoader().load(yaml.load(yml)))
dev = Device(host='router', user='username', password='password' )
dev.open(gather_facts=False)
table = RsvpTable(dev)
table.get()
# get specific view from table
find = table['INSERT_RSVP_SESSION_NAME_HERE']
print find.source_address
print find.destination_address
print find.lsp_state
# Iterate over RsvpTable
for view in table:
print view.name
for field in view.keys():
print " {}: {}".format(field, view[field])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment