Skip to content

Instantly share code, notes, and snippets.

@fredhsu
fredhsu / kubeadm-docker-ubuntu.sh
Last active May 16, 2019 07:33
Install docker for kubeadm on Ubuntu
# Install Docker from Ubuntu's repositories:
sudo apt-get update
sudo apt-get install -y docker.io
# or install Docker CE 18.06 from Docker's repositories for Ubuntu or Debian:
## Install prerequisites.
sudo apt-get update && sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
@fredhsu
fredhsu / start-ec2-tag.sh
Created May 18, 2018 20:05
Start all ec2 instances with a specific usage tag
aws ec2 start-instances --instance-ids $(aws ec2 describe-instances --filters "Name=tag:Usage,Values=kube" --query 'Reservations[*].Instances[*].[InstanceId]' --output text)
@fredhsu
fredhsu / odl-stats.py
Last active May 7, 2018 13:34
OpenDayLight REST API call using Python getting flow statistics
import httplib2
import json
h = httplib2.Http(".cache")
h.add_credentials('admin', 'admin')
#resp, content = h.request('http://10.55.17.20:8080/controller/nb/v2/statistics/default/flowstats', "GET")
# Updated 8 SEP 2013 to reflect new REST API
resp, content = h.request('http://10.55.17.20:8080/controller/nb/v2/statistics/default/flow', "GET")
allFlowStats = json.loads(content)
flowStats = allFlowStats['flowStatistics']
@fredhsu
fredhsu / local.conf
Created January 11, 2014 15:47
Local.conf file for devstack using Neutron, ML2, and allowing connectivity to an external switch
[[local|localrc]]
HOST_IP=172.22.28.204
# Interface connected to switch
FLAT_INTERFACE=eth1
# Logging settings
LOGDAYS=1
LOGFILE=$DEST/logs/stack.sh.log
SCREEN_LOGDIR=$DEST/logs/screen
@fredhsu
fredhsu / addquotes.sh
Created April 6, 2017 17:35
One liner to add quotes, a carriage return, and a trailing comma with sed
sed 's/.*/"&\\n",/'
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DeriveGeneric #-}
import Data.Aeson
import Data.Text
import GHC.Generics
import Network.Wreq
import Control.Lens
import qualified Data.ByteString.Lazy as B
@fredhsu
fredhsu / eAPI-simple.ps1
Last active September 12, 2016 10:48
eAPI from Powershell
$username = "admin"
$password = "admin"
$switchIp = "172.22.28.157"
#URL
$eApiUrl = "https://$switchIp/command-api"
# Command(s) we want to send
$cmds = @('show version')
@fredhsu
fredhsu / AristaOMIPowerShell.ps1
Created January 28, 2014 02:03
Example PowerShell script for talking to an Arista Switch via OMI
# Create an object which represents session options
# -SkipCACheck and -SkipCNCheck are used to skip SSL certificate checks
$so = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl
# Switch credentials
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential( "admin", $password )
# Create a session to the switch
$switch = "172.22.28.159"
@fredhsu
fredhsu / net.30.toml
Created May 26, 2016 23:38
TOML config file for macvlan driver
[macvlan]
version = "0.1"
parent = "bond0.30"
#!/bin/bash
#
###########################################
### Swarm Global Macvlan Driver Tests ###
### ./global-vlan-test.sh <Swarm_IP> ###
##########################################
# runswarm takes the swarm host:port and network and runs four containers on that network, then removes them
function runswarm {
echo "Creating four containers on network {$2}"