This is similar to NETCONF RPC edit-config with replace
pytraining@newhostname# show protocols bgp
log-updown;
group underlay {
type external;
import bgp-in;
export bgp-out;
local-as 209;
from jnpr.junos import Device | |
from lxml import etree | |
dev=Device(host="xxx", user="xxx", password="xxx") | |
dev.open() | |
test1=dev.rpc.ping(host="8.8.8.8") | |
print etree.tostring(test1) | |
test2=dev.rpc.traceroute(host="8.8.8.8") | |
print etree.tostring(test2) | |
#or use StartShell object and issue (cli- c “ping 10.101.2.2 count 5 rapid”) |
This is similar to NETCONF RPC edit-config with replace
pytraining@newhostname# show protocols bgp
log-updown;
group underlay {
type external;
import bgp-in;
export bgp-out;
local-as 209;
from lxml import etree | |
from jnpr.junos import Device | |
dev=Device(host="172.30.54.108", user="lab", password='m0naco') | |
dev.open() | |
result=dev.rpc.get_interface_information(level_extra="descriptions") | |
type(result) | |
print (etree.tostring(result)) | |
etree.dump(result) | |
dev.close() |
# This python scripts extract and print the ip addresses of all EX4300-48T from junos space | |
# usage: python junos_space_rest_calls.py | |
from pprint import pprint as pp | |
from requests import get | |
from requests.auth import HTTPBasicAuth | |
''' | |
https://www.juniper.net/techpubs/en_US/junos-space-sdk/13.3/apiref/com.juniper.junos_space.sdk.help/JSInventoryManagerSVC/Docs/rest.managed-elements.html | |
''' |
''' | |
pytraining@ex4300-9> start shell | |
% pwd | |
/var/home/remote | |
% show version | |
show: Command not found. | |
% cli -c 'show version' | |
fpc0: | |
-------------------------------------------------------------------------- | |
Hostname: ex4300-9 |
""" | |
Description: | |
I am using this script to add an MIT license to the Github repositories (master branch) of my personal github account. | |
It first get the lists all repositories from a personal github account, and then add an MIT license to each of them. | |
To exclude some repositories, I am using the variable ```repo_to_skip``` | |
To use an explicit list of repositories, I am using the variable ```repo_list``` | |
MIT license details used: | |
Year: '2018' | |
copyright holders: 'Juniper Networks, Inc. All rights reserved' |
''' | |
python -V | |
Python 3.7.7 | |
pip freeze | grep paramiko | |
paramiko==2.7.1 | |
''' | |
import paramiko | |
import time |
With the telegraf gnmi input plugin, in order to use the telegraf timestamps instead of using the devices timestamps:
Here's the fork https://github.com/rski/telegraf that was used for:
influxdata/telegraf#8411
influxdata/telegraf#8420
Until this option will become natively part of Telegraf (influxdata/telegraf#8689), you can build a docker image from this fork:
git clone https://github.com/rski/telegraf
cd telegraf
import requests | |
from jinja2 import Template | |
url = "https://api.github.com/users/ksator/repos?per_page=100&sort=pushed" | |
projects = requests.get(url) | |
if projects.status_code == 200: | |
for project in projects.json(): | |
print(project['name']) |