Skip to content

Instantly share code, notes, and snippets.

@ksator
ksator / projects.py
Created July 21, 2021 00:20
list all repositories
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'])
@ksator
ksator / how_to_use_telegraf_timestamps.md
Last active April 21, 2021 08:13
How to use telegraf timestamps with the telegraf gnmi input plugin instead of using the devices timestamps
@ksator
ksator / arista_paramiko.py
Created May 18, 2020 23:09
ssh arista EOS devices using paramiko
'''
python -V
Python 3.7.7
pip freeze | grep paramiko
paramiko==2.7.1
'''
import paramiko
import time
@ksator
ksator / github.py
Last active October 2, 2018 08:08
update all your repos with an MIT license
"""
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'
@ksator
ksator / startshell.py
Last active September 5, 2018 22:05
start shell on junos using pyez
'''
pytraining@ex4300-9> start shell
% pwd
/var/home/remote
% show version
show: Command not found.
% cli -c 'show version'
fpc0:
--------------------------------------------------------------------------
Hostname: ex4300-9
@ksator
ksator / junos_space_rest_calls.py
Last active January 22, 2018 18:32
This python scripts make REST calls to Junos space to extract and print the ip addresses of all EX4300-48T
# 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
'''
@ksator
ksator / rpc_with_an_arg_to_Junos_using_pyez.py
Last active January 12, 2018 02:08
pass an rpc with an arg to Junos using pyez
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()
@ksator
ksator / how_to_load_replace_terminal_on_Junos.md
Last active July 30, 2022 05:30
"load replace terminal" on Junos

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;
@ksator
ksator / ping_and_traceroute_from_pyez.py
Last active July 18, 2021 20:56
ping and traceroute from pyez
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”)