Skip to content

Instantly share code, notes, and snippets.

View jeffbrl's full-sized avatar

Jeff Loughridge jeffbrl

View GitHub Profile
@jeffbrl
jeffbrl / set_nd_proxy_entries.sh
Last active August 29, 2015 14:04
Script to configure IPv6 ND proxy
#!/bin/bash
#
# Jeff Loughridge
# July 2014
# jeffl at brooksconsulting-llc.com
# This script provides an example of setting up IPv6 static
# ND proxy entries. Edit the V6_START to match
# what you see in the DO control panel
@jeffbrl
jeffbrl / mdserv
Last active August 29, 2015 14:10 — forked from smoser/mdserv
#!/usr/bin/python
"""
To use this to mimic the EC2 metadata service entirely, run it like:
# where 'eth0' is *some* interface. if i used 'lo:0' i got 5 second or so delays on response.
sudo ifconfig eth0:0 169.254.169.254 netmask 255.255.255.255
sudo ./mdserv 169.254.169.254:80
Then:
wget -q http://169.254.169.254/latest/meta-data/instance-id -O -; echo
curl --silent http://169.254.169.254/latest/meta-data/instance-id ; echo
@jeffbrl
jeffbrl / virsh-get-ip.sh
Created November 22, 2014 17:37
Obtain KVM guest IPv4 or IPv6 from MAC adddress
#!/bin/bash
#
function get_ip {
# Obtain the IPv4 or IPv6 address
VERSION=$1
# Use arp to find the IP address you're looking for via its MAC address:
IP=$(ip -$VERSION neighbor show | grep $MAC_ADDRESS | awk '{ print $1 }' )
@jeffbrl
jeffbrl / sprayer.lua
Created January 5, 2015 01:13
First Example for Snabbswitch Getting Started Guide - sprayer.lua
#!/usr/bin/env snabbswitch
local app = require("core.app")
local config = require("core.config")
local pcap = require("apps.pcap.pcap")
local link = require("core.link")
local RawSocket = require("apps.socket.raw")
local c = config.new()
config.app(c, "capture", pcap.PcapReader, "input.pcap")
@jeffbrl
jeffbrl / get_flow.py
Created April 23, 2015 18:16
Pyez parsing lxml Element example
#!/usr/bin/env python
from jnpr.junos import Device
def build_dict(xml):
jflow = {}
# 1st entry in xml is <inline_jflow_flow_information>
inline_jflow_flow_information = xml[0]
@jeffbrl
jeffbrl / get_rsvp.py
Created April 24, 2015 18:40
Pyez RSVP Table/View
#!/usr/bin/env python
import yaml
from jnpr.junos.factory.factory_loader import FactoryLoader
from jnpr.junos import Device
yml = '''
---
RsvpTable:
rpc: get-rsvp-session-information
@jeffbrl
jeffbrl / pyez_set.py
Created June 26, 2015 15:48
PyEZ Configuration actions
#!/usr/bin/env python
import sys
from jnpr.junos.utils.config import Config
from jnpr.junos import Device
from jnpr.junos.exception import *
jdev = Device(user='jeffl', host='10.10.10.1', password='pass123')
jdev.open(gather_facts=False)
@jeffbrl
jeffbrl / rro_display.slax
Last active September 11, 2015 17:50
Slax script to display RRO
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> {
@jeffbrl
jeffbrl / NameCheckLibrary.py
Created September 16, 2015 15:42
Test Library for use with NameCheck.py (robot framework example)
from NameCheck import NameChecker
class NameCheckLibrary():
def __init__(self):
self._namechecker = NameChecker()
self._name = None
self._result = None
def Set_name(self, name):
@jeffbrl
jeffbrl / NameCheck.py
Last active September 16, 2015 15:43
Simple class to be tested (robot framework example)
#!/usr/bin/env python
class NameChecker(object):
def __init__(self):
self._name = None
def set_name(self, name):
self._name = name