Created
April 24, 2015 18:40
-
-
Save jeffbrl/e628a12c73c9a17d0008 to your computer and use it in GitHub Desktop.
Pyez RSVP Table/View
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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