Skip to content

Instantly share code, notes, and snippets.

View plajjan's full-sized avatar

Kristian Larsson plajjan

View GitHub Profile
query_parts.append({
'operator': 'or',
'val1': {
'operator': 'or',
'val1': {
'operator': 'or',
'val1': {
'operator': 'or',
'val1': {
'operator': 'regex_match',
Simple dictSQL to match on one column using the equal operator. val1 contains name of column/attribute name of prefix to match while val2 contains the value it should match using the specified operator.
dictSQL = {
'val1': 'description',
'operator': 'equals',
'val2': 'bar'
}
Expands to:
description = 'bar'
@plajjan
plajjan / mocktest.py
Last active January 3, 2016 06:29
Python import mocking
""" Trying to mock my imports as I don't need this code to run, only load so
that readthedocs.org can generate nice documentation from my docstrings.
"""
#!/usr/bin/python
import sys
class Mock(object):
def __init__(self, *args, **kwargs):
#!/usr/bin/env python3
import json
import re
import urllib.request
def expand_asset(as_set):
pass
#!/usr/bin/env python
# Get YANG models from a device by using the get-schema RPC.
#
# Kristian Larsson <[email protected]>
#
import urlparse
import logging
from ncclient import manager
import ncclient
@plajjan
plajjan / docker-commands
Created December 23, 2016 15:08
XR config for simple ISIS topology
Start three XR routers:
kll@htpc:~$ docker run --privileged -i -t -d --name xr1 vr-xrv:6.0.1
1d520dde91768a6dc2ee24873f46e3045b2c805e322d3556288080be9a9f6165
kll@htpc:~$ docker run --privileged -i -t -d --name xr2 vr-xrv:6.0.1
15a26c2ea190bd02df952ab90271b865811a1fdbcf9b4626da868297e9f0214f
kll@htpc:~$ docker run --privileged -i -t -d --name xr3 vr-xrv:6.0.1
059ea393bbc90c79c51cba79fa3f1c1dbc4e4dedbddf742f1f92400c6407847e
kll@htpc:~$
Connect them together, the first interface on xr1 goes to the first interface
root@NIPAP-Demo:~# cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
@plajjan
plajjan / docker-compose.yml
Last active October 11, 2023 10:17
NIPAP docker compose
nipap-db:
image: nipap/postgres-ip4r
volumes:
- ./db-data:/var/lib/postgresql/data
environment:
- PGDATA=/var/lib/postgres/data/pgdata
- POSTGRES_USER=nipap
- POSTGRES_PASSWORD=S3cretDBPas5
- POSTGRES_DB=nipap
@plajjan
plajjan / .gitlab-ci.yml
Last active May 25, 2022 11:40
Git automation stuff
image: gitlab.dev.terastrm.net:4567/terastream/cisco-nso/ci-cisco-nso:4.2.3
stages:
- build
- mr-robot
variables:
NCS_VERSION: "4.2.3"
DOCKER_REGISTRY: "gitlab.dev.terastrm.net:4567/terastream/cisco-nso"
TARGET_REGISTRY: "repo.dev.terastrm.net:5000/"
@plajjan
plajjan / foo.py
Last active June 25, 2018 21:46
NCS live-status get example
class Selftest(Action):
@Action.action
def cb_action(self, uinfo, name, kp, action_input, action_output):
out = action_output.somewhere
with ncs.maapi.single_write_trans('python-state-backbone-interface-write', 'system', db=ncs.OPERATIONAL) as t:
root = ncs.maagic.get_root(t)
service = ncs.maagic.get_node(t, kp)