Skip to content

Instantly share code, notes, and snippets.

View drnic's full-sized avatar
🏆
Platinum Status Level

Dr Nic Williams drnic

🏆
Platinum Status Level
View GitHub Profile
@drnic
drnic / example-result.txt
Created February 5, 2014 14:39
What are all the IPs currently being used by an OpenStack tenant across all networks? Run this fog command
["192.168.101.4", "174.128.50.29", "192.168.101.3", "192.168.100.12", "174.128.50.28", "192.168.100.16", "10.0.28.20", "192.168.100.15", "174.128.50.5", "10.0.255.52", "10.0.28.14", "192.168.100.13", "10.0.28.15", "192.168.100.10", "174.128.50.9", "10.0.28.16", "10.0.28.13", "10.0.28.12", "192.168.100.11", "10.0.28.11", "10.0.28.7", "192.168.100.9", "10.0.28.6", "192.168.100.8", "192.168.100.6", "174.128.50.17", "10.0.28.5"]
@drnic
drnic / fog.md
Last active August 29, 2015 13:56
Navigating around openstack networks

Given a router, get the attached external gateway's pool name:

floating_ip_pool_name = network.networks.get(router.external_gateway_info["network_id"]).name
# => "IO.IP"

Use the pool name to provision a floating IP:

@drnic
drnic / rebuild.sh
Created February 5, 2014 18:55
rebuild bosh-lite including CF
#!/usr/bin/env bash
set -x
set -e
export CF_VERSION=v154
export CF_RELEASE_DIR=${CF_RELEASE_DIR:-"$HOME/Projects/bosh_releases/cf-release"}
export TEST_APP_DIR=${TEST_APP_DIR:-"$HOME/Sites/cloudfoundry_apps/service-binding-proxy"}
export BROKER_DIR=${BROKER_DIR:-"$HOME/Sites/servaas"}
@drnic
drnic / Dockerfile
Created February 8, 2014 17:30
Dockerfile to compile Ruby 2.1.0 from source
FROM stackbrew/ubuntu:saucy
MAINTAINER Dr Nic Williams
# reduce output from debconf
ENV DEBIAN_FRONTEND noninteractive
# 'apt-get update' always return 0. we should check actually updated.
RUN apt-get update | tee /tmp/apt-update_output
RUN ! (grep '^Err' /tmp/apt-update_output)

Run docker server on a fresh folder:

docker -d -g /home/core/docker-build/ -p /var/run/docker-build.pid -H tcp://127.0.0.1:5011

In the gnatsd-dockerfile project:

docker -H localhost:5011 build -t localhost:5011/gnatsd .
Pulling ubuntu image from public registry
```
core@localhost ~ $ docker -H tcp://localhost:5011 pull ubuntu:13.04
Pulling repository ubuntu
eb601b8965b8: Download complete
511136ea3c5a: Download complete
f323cf34fd77: Download complete
core@localhost ~ $ docker -H tcp://localhost:5011 images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
@drnic
drnic / private-docker-play.md
Last active August 29, 2015 13:56
Playing with explicit docker daemon and registry

Running local fresh docker in a terminal:

mkdir -p /home/core/docker1
sudo docker -d -g /home/core/docker1 -p /var/run/docker1.pid -H tcp://127.0.0.1:5011

Pulling ubuntu image from public registry into that docker (in another terminal):

$ docker logs -f skydock
[info] 1392353435 skydock: loading plugins from /plugins/default.js
[debug] 1392353435 skydock: starting restore of containers
[info] 1392353435 skydock: adding 10d3ea0995 (skydns) to skydns
[debug] 1392353435 skydock: starting main process
[debug] 1392353435 skydock: received event (start) 0f231d44eb6271ab82976ba1829dcb53483b8983e20c88c3f410408ff0060a9b crosbymichael/skydock:latest
[info] 1392353435 skydock: adding 0f231d44eb (skydock) to skydns
[debug] 1392353582 skydock: received event (die) 10d3ea09958ab0771cb12ed36131a4d35099e00127ac05c88de4dd3aebc78e53 crosbymichael/skydns:latest
[info] 1392353582 skydock: removing 10d3ea0995 from skydns
[debug] 1392353582 skydock: received event (stop) 10d3ea09958ab0771cb12ed36131a4d35099e00127ac05c88de4dd3aebc78e53 crosbymichael/skydns:latest
@drnic
drnic / snippets.md
Last active August 29, 2015 13:56
AWS VPC fog snippets

Find a RouteTable for a given public Subnet:

subnet = Fog::Compute["aws"].subnets.last
subnet_id = subnet.subnet_id

rts = Fog::Compute["aws"].route_tables
route_table_for_subnet = rts.find {|rt| rt.associations.find {|assoc| assoc["subnetId"] == subnet_id} }
root@drbd-0:~# drbdadm create-md r0
md_offset 5242875904
al_offset 5242843136
bm_offset 5242679296
Found some data
==> This might destroy existing data! <==
Do you want to proceed?