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
*** Settings *** | |
Documentation Example test cases using the keyword-driven testing approach. | |
Library NameCheckLibrary.py | |
*** Test Cases *** | |
Test for validity | |
Set name Bruce | |
Result should be ${true} | |
Test for invalidity |
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
# code courtesy of shermdog on pyez google group | |
from jnpr.junos import Device | |
dev = Device(host='IP', user='user', passwd='password') | |
dev.open() | |
config = dev.rpc.get_config() | |
from lxml import etree |
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
from api_consumer.api_consumer import ApiConsumer | |
import unittest | |
import unittest.mock | |
import json | |
class TestApiConsumer(unittest.TestCase): | |
def setUp(self): | |
self.ac = ApiConsumer() |
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
version 1.1; | |
/* usage: slaxproc -r test.slax input.xml */ | |
match / { | |
for-each(//isis-interface) { | |
<interface-name>interface-name; | |
} | |
} |
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
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 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 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 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 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 |
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
# test with | |
# curl -X POST -H "Content-Type: application/json" -d '{ "action" : "RUN"}' | |
# http://127.0.0.1:5000/example/ | |
import json | |
from flask import request, url_for | |
from flask.ext.api import FlaskAPI, status, exceptions | |
app = FlaskAPI(__name__) |