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"; | |
import "../import/junos.xsl"; | |
match / { |
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"; | |
import "../import/junos.xsl"; | |
match / | |
{ | |
<op-script-results> { |
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 | |
class NameChecker(object): | |
def __init__(self): | |
self._name = None | |
def set_name(self, name): | |
self._name = 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
from NameCheck import NameChecker | |
class NameCheckLibrary(): | |
def __init__(self): | |
self._namechecker = NameChecker() | |
self._name = None | |
self._result = None | |
def Set_name(self, 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
*** 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
# 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__) |
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 lxml import etree | |
from jnpr.junos.jxml import remove_namespaces | |
# file contains output of 'show interfaces ge-0/0/0.0' | |
fh = open('router_output2.xml', 'r') | |
parser = etree.XMLParser(remove_blank_text=True) | |
tree = etree.parse(fh, parser) | |
tree = remove_namespaces(tree) |
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 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] |
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() |