Skip to content

Instantly share code, notes, and snippets.

@ajayhn
ajayhn / openstack-create-qcow2-snapshot
Created March 27, 2015 02:27
openstack-create-qcow2-snapshot
In this example, an instance was launched with flavor 80G. installation didn't consume much of the disk. When snapshot was created without below steps its size was 80G (since openstack has raw in _base and snapshot creates with that raw size). By doing below (pull ing from _base to disk, qcow2 without the raw backing file reduces size of snapshot).
root@a6s15:/var/lib/nova/instances/ed719037-2e00-4c4c-90f9-924578f93b80# qemu-img info disk
image: disk
file format: qcow2
virtual size: 80G (85899345920 bytes)
disk size: 77M
cluster_size: 65536
** backing file: /var/lib/nova/instances/_base/1d043087def843d5e081c1e2c3ea6ca1e4278547 **
Format specific information:
@ajayhn
ajayhn / simple-gw-with-internet-access
Last active January 30, 2018 22:02
Simple gateway from compute using iptables from vgw1 to vhost0 on linux host
This assumes a single net n1 with 1.1.1.0/24 and vgw1 interface. Can be extended to use a public net and vgw1 on the public net
python /opt/contrail/utils/provision_vgw_interface.py --oper create --interface vgw1 --subnets 1.1.1.0/24 --routes 0.0.0.0/0 --vrf default-domain:admin:n1:n1
If you run into error running above script, instead of `import InstanceService` and `import ttypes` use
`from contrail_vrouter_api.gen_py.instance_service import InstanceService, ttypes`
Now do `ifconfig` and verify `vgw1` is present
@ajayhn
ajayhn / ifmap_search.py
Created September 3, 2015 21:33
ifmap-search
#!/usr/bin/python
import logging
from pprint import pformat
import argparse
import sys
reload(sys)
sys.setdefaultencoding('UTF8')
import lxml.etree as et
#!/usr/bin/python
# Example Usage:
# ./shell.py "ls /" quit
# ./shell.py "ls /project" quit
# ./shell.py "ls /project/default-domain:default-project" quit
# ./shell.py "ls /project/default-domain:default-project/virtual_networks" quit
# ./shell.py "cat /project/default-domain:default-project" quit
# ./shell.py "cat -p /project/default-domain:default-project" quit
# ./shell.py "cat /project/default-domain:admin/virtual_networks/default-domain:default-project:default-virtual-network" quit
@ajayhn
ajayhn / contrail-controller-dockerfile.r3.0
Last active January 30, 2018 21:31
contrail-controller-dockerfile.r3.0
FROM ubuntu:14.04
# e.g. docker build --build-arg REPO_URL=http://hajay-repo:8080/kilo-3.0.0.0-2723-kilo/ --build-arg REPO_DIST=opencontrail-R3.0 .
ARG REPO_URL=http://hajay-repo:8080/kilo-3.0.0.0-2723-kilo/
ARG REPO_DIST=opencontrail-R3.0
RUN echo "deb ${REPO_URL} ${REPO_DIST} main" >> /etc/apt/sources.list.d/opencontrail.list
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated curl strace tcpdump
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --allow-unauthenticated cassandra zookeeper rabbitmq-server
@ajayhn
ajayhn / coreos-on-do.sh
Created September 27, 2017 16:47
coreos-on-do.sh
#!/bin/bash
set -e
# Forked from https://raw.githubusercontent.com/ibuildthecloud/coreos-on-do/master/coreos-on-do.sh
CHANNEL=${CHANNEL:-alpha}
VERSION=${VERSION:-current}
install_kexec()
{
@ajayhn
ajayhn / README.md
Created September 26, 2017 22:14 — forked from andyshinn/README.md
CoreOS on Digital Ocean using Terraform

Terraform, CoreOS, and Digital Ocean

Let's use Terraform to easily get a CoreOS cluster up on Digital Ocean. In this example we will get a 5 node CoreOS cluster up and running on the Digital Ocean 8GB size.

Install Terraform

Grab a copy of Terraform for your platform from http://www.terraform.io/downloads.html. Follow the instructions at http://www.terraform.io/intro/getting-started/install.html by getting Terraform in your PATH and testing that it works.

Digital Ocean API Key

@ajayhn
ajayhn / .tmux.conf
Last active June 5, 2017 02:50
tmux settings
# unset C-b as leader and set backtick as leader
unbind C-b
set-option -g prefix `
# backtick+e for backtick
bind e send-prefix
# backtick+backtick for toggle
bind ` last-window
@ajayhn
ajayhn / az01-churches.geojson
Last active May 16, 2017 21:40
List of Churches at AZ-01 congressional district.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ajayhn
ajayhn / db-json-exim.py
Last active December 6, 2016 19:19
db-json-exim
# Usage: python db-json-exim.py --import-from /import-data/db.json
import sys
reload(sys)
sys.setdefaultencoding('UTF8')
import logging
import argparse
import gzip
import json
import cgitb
import gevent