Skip to content

Instantly share code, notes, and snippets.

{-# 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 / 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}"
@fredhsu
fredhsu / docker-net-22-MAR-2016
Last active March 22, 2016 19:05
Docker network options
fredlhsu@lnx151:~$ ./docker-latest -v
Docker version 1.11.0-dev, build 6c2f438, experimental
# Here is the event stream from Swarm:
fredlhsu@lnx151:~$ ./docker-latest -H tcp://0.0.0.0:2376 events
2016-03-22T11:44:16.041037643-07:00 network create 4422a2fea7ccd0557ccbbb3651ee66399949336a6f82e49241e3386e803b9212 (name=ipv5, node.addr=172.28.168.151:2375, node.id=KUWR:KH3W:TWU6:AUK7:KONN:4KEW:D5LR:BIPL:4TFZ:O4LY:M4VH:O5UA, node.ip=172.28.168.151, node.name=lnx151, type=ipvlan)
2016-03-22T11:47:24.156619183-07:00 network create aa2c342501069d342e9091b9f05ad94f38624811088de4ae736fcf9301db8d1a (name=mcv1, node.addr=172.28.168.151:2375, node.id=KUWR:KH3W:TWU6:AUK7:KONN:4KEW:D5LR:BIPL:4TFZ:O4LY:M4VH:O5UA, node.ip=172.28.168.151, node.name=lnx151, type=macvlan)
2016-03-22T11:52:33.938128421-07:00 network create eb5f3c34dd422ce428ee1d3087ed5b0e5e8957a567086fbf8bf5f092eb43df9f (name=testbridge, node.addr=172.28.168.151:2375, node.id=KUWR:KH3W:TWU6:AUK7:KONN:4KEW:D5LR:BIPL:4TFZ:O4LY:M4VH:O5UA, node.ip=172.28.168.151, no
@fredhsu
fredhsu / macvlan-bridge.txt
Last active March 7, 2016 23:42
Running Docker macvlan bridge mode with a ToR Arista switch
# switch config
interface Ethernet24
description r18-u34-svr2
no switchport
ip address 192.168.1.1/24
# Docker commands
$ docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o host_iface=enp5s0f0 mac_net100
@fredhsu
fredhsu / ipvlan-l2-dot1q.txt
Last active March 7, 2016 23:41
Docker ipvlan L2 mode with 802.1q trunk with Arista ToR
# Switch config
vlan 20,30
!
interface Ethernet48
switchport mode trunk
!
interface Vlan20
ip address 192.168.20.1/24
!
interface Vlan30
[package]
name = "ovsdb"
version = "0.1.0"
authors = ["fredlhsu <fredlhsu@aristanetworks.com>"]
[dependencies.serde]
serde = "*"
[dependencies.serde_macros]
serde_macros = "*"
@fredhsu
fredhsu / eapi.rs
Created June 23, 2015 21:24
Using Rust/Hyper to do a HTTP Post with JSON
extern crate hyper;
extern crate core;
use std::io::Read;
use hyper::Client;
use hyper::header::Connection;
use hyper::header::Basic;
use hyper::header::Headers;
use core::str::FromStr;
@fredhsu
fredhsu / ChanPipelinesEapi.go
Created January 19, 2015 15:53
Go Pipelines with Arista eAPI
package aristalabstatus
import (
"encoding/json"
"flag"
"fmt"
"github.com/fredhsu/eapigo"
"io/ioutil"
"net/http"
"os"
import json
from jsonrpclib import Server
switches = ["bleaf1", "bleaf2", "bleaf3", "bleaf5"]
username = "admin"
password = "admin"
for switch in switches:
urlString = "https://{}:{}@{}/command-api".format(username, password, switch)
switchReq = Server( urlString )