This file contains hidden or 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
| version 1.1; | |
| /* usage: slaxproc -r test.slax input.xml */ | |
| match / { | |
| for-each(//isis-interface) { | |
| <interface-name>interface-name; | |
| } | |
| } |
This file contains hidden or 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
| version 1.0; | |
| ns junos = "http://xml.juniper.net/junos/*/junos"; | |
| ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; | |
| ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; | |
| ns func extension = "http://exslt.org/functions"; | |
| ns automation = "http://xml.juniper.net/automation"; | |
| import "../import/junos.xsl"; |
This file contains hidden or 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
| version 1.0; | |
| ns junos = "http://xml.juniper.net/junos/*/junos"; | |
| ns xnm = "http://xml.juniper.net/xnm/1.1/xnm"; | |
| ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0"; | |
| ns exsl extension = "http://exslt.org/common"; | |
| ns func extension = "http://exslt.org/functions"; | |
| ns automation = "http://xml.juniper.net/automation"; | |
| import "../import/junos.xsl"; |
This file contains hidden or 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
| # This task gets all Junos configuration from all devices | |
| - name: Get configuration | |
| hosts: all | |
| connection: local | |
| gather_facts: no | |
| roles: | |
| - Juniper.junos | |
| vars_prompt: | |
| - name: USER | |
| prompt: Device user |
This file contains hidden or 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
| # This task pushes Junos config files to devices | |
| - name: Get configuration | |
| hosts: all | |
| connection: local | |
| gather_facts: no | |
| roles: | |
| - Juniper.junos | |
| vars_prompt: | |
| - name: USER | |
| prompt: Device user |
This file contains hidden or 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 python3 | |
| from functools import wraps | |
| def add_sandwich(wrapped): | |
| ''' add_sandwich doc_string ''' | |
| # try commenting out the next line to see what happens | |
| @wraps(wrapped) | |
| def wrapper(*args, **kwargs): |
This file contains hidden or 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
| # Playbook for executing CLI commands with output to text files | |
| # | |
| # Single host: | |
| # ansible-playbook -i "router_name_here," -e '{ "CMD": "your_command_here" }' run-junos-cmds.yml | |
| # Multiple hosts: | |
| # ansible-playbook -i inventory_file -e '{ "CMD": "your_command_here" }' run-junos-cmds.yml | |
| - name: Run CLI commands | |
| hosts: all | |
| connection: local |
This file contains hidden or 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
| from __future__ import print_function | |
| import jxmlease | |
| # Accessing current time from get-system-uptime | |
| with open('get-system-uptime.xml') as xml: | |
| root = jxmlease.parse(xml) | |
| uptime = root['rpc-reply']['system-uptime-information']['current-time']['date-time'].get_cdata() | |
| print("uptime: {}".format(uptime)) | |
| print('\n===============\n') |
This file contains hidden or 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 | |
| # portions of this code derived from samples directory of the jsnapy project | |
| from __future__ import print_function | |
| import sys | |
| import time | |
| from jnpr.jsnapy import SnapAdmin | |
| from pprint import pprint |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |