Skip to content

Instantly share code, notes, and snippets.

View plajjan's full-sized avatar

Kristian Larsson plajjan

View GitHub Profile
@plajjan
plajjan / dict_impl.c
Last active November 22, 2021 22:26
builtin/dict_impl.c
/*
* Copyright (C) 2019-2021 Data Ductus AB
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@plajjan
plajjan / keybase.md
Created December 16, 2018 23:10
keybase.md

Keybase proof

I hereby claim:

  • I am plajjan on github.
  • I am kll (https://keybase.io/kll) on keybase.
  • I have a public key whose fingerprint is 09D0 9FB4 7CBC 93C7 4612 812B A726 6380 C5C2 7251

To claim this, I am signing this object:

@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)
@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 / 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
root@NIPAP-Demo:~# cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin operator@spritelink.net
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
@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
#!/usr/bin/env python
# Get YANG models from a device by using the get-schema RPC.
#
# Kristian Larsson <kristian@spritelink.net>
#
import urlparse
import logging
from ncclient import manager
import ncclient
#!/usr/bin/env python3
import json
import re
import urllib.request
def expand_asset(as_set):
pass
@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):