Skip to content

Instantly share code, notes, and snippets.

@rtomaszewski
rtomaszewski / rax-list-cs-ips.sh
Last active Aug 29, 2015
list Openstack Rackspace cloud servers ip in more readable way
View rax-list-cs-ips.sh
nova list | egrep -v 'ID|-----' | awk -F'|' '{print $2 }' | ( echo 'name pub-new(rc) ip priv-net ip init-net ip' ; while read cs; do nova show $cs | egrep ' name |accessIPv4|public network|private' | awk -F"|" '{for (i=1;i<=NF;i++) gsub (/^ */,"",$i); print $2,$3}' | sort | xargs echo | awk ' { print $4,$1,$2,$5,$6,$7,$8 }'; done ) | column -t
name pub-new(rc) ip priv-net ip init-net ip
APP01 accessIPv4 1.2.3.141 privatenetwork 10.208.64.184 publicnetwork 1111:1a11:1111:2222:3333:2222:ff08:a1ce,11.13.12.17
APP01 accessIPv4 1.2.3.140 privatenetwork 10.208.97.95 publicnetwork 11.13.140.6,1111:2222:3333:4444:5555:ae11:ff08:70b5
APP02 accessIPv4 1.2.3.238 privatenetwork 10.208.97.115 publicnetwork 11.13.140.46,1111:2222:3333:4444:5555:ae11:ff08:9586
APP03 accessIPv4 1.2.3.142 privatenetwork 10.208.102.109 publicnetwork 11.13.177.167,1111:2222:3333:4444:5555:ae11:ff08:1300
View default-pool.sh
# default pool
create ltm pool pool-vip-80
modify ltm pool pool-vip-80 members add { 1.1.1.1:80 { session disabled state down } }
modify ltm pool pool-vip-80 monitor http
# let' add some cloud servers manually
modify ltm pool pool-vip-80 { members add { 10.208.1.1:80 } }
# use the Rackconnect metadata feature
@rtomaszewski
rtomaszewski / vip-http.sh
Created Mar 2, 2014
create a default http vip
View vip-http.sh
# http vip
create ltm virtual vs-vip-80 destination 192.168.199.111:http
modify ltm virtual vs-vip-80 { profiles replace-all-with { tcp { } } }
modify lmt virtual vs-vip-80 { profiles add { http } }
modify ltm virtual vs-vip-80 { pool pool-vip-80 }
View custom-pools.sh
create ltm pool pool-vip-80-url1
modify ltm pool pool-vip-80-url1 members add { 1.1.1.1:80 { session disabled state down } }
modify ltm pool pool-vip-80-url1 monitor http
modify ltm pool pool-vip-80-url1 { members add { ip:port } }
create ltm pool pool-vip-80-url2
modify ltm pool pool-vip-80-url2 members add { 1.1.1.1:80 { session disabled state down } }
modify ltm pool pool-vip-80-url2 monitor http
modify ltm pool pool-vip-80-url2 { members add { ip:port } }
@rtomaszewski
rtomaszewski / gist-type-command.c
Created Mar 30, 2014
Uses stdin of the shell to simulate input string and type a command to run.
View gist-type-command.c
#include <strings.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@rtomaszewski
rtomaszewski / vmware-workstation-xenserver.conf
Created May 14, 2014
VMware Workstation VM config for XenServer
View vmware-workstation-xenserver.conf
.encoding = "windows-1252"
config.version = "8"
virtualHW.version = "8"
numvcpus = "4"
scsi0.present = "TRUE"
scsi0.virtualDev = "lsilogic"
memsize = "4096"
scsi0:0.present = "TRUE"
scsi0:0.fileName = "xenserver5.vmdk"
ide1:0.present = "TRUE"
View spin-vm.sh
#!/bin/bash
set -e
set -x
template=`xe template-list name-label="Ubuntu Lucid Lynx 10.04 (64-bit)" --minimal`
vm=`xe vm-install template=$template new-name-label=vm-label`
network=`xe network-list bridge=xenbr0 --minimal`
vif=`xe vif-create vm-uuid=$vm network-uuid=$network device=0`
xe vm-param-set uuid=$vm other-config:install-repository=http://archive.ubuntu.com/ubuntu
@rtomaszewski
rtomaszewski / import-vms.sh
Created May 17, 2014
create more vms using the import functions from xenserver
View import-vms.sh
xe vm-export filename=vm-label1-export1.xva vm=vm-label
for i in $(seq 2 10); do
name="vm-$i"
echo -n "creating vm $name "
uuid=$(xe vm-import filename=vm-label1-export1.xva preserve=false)
xe vm-param-set name-label=$name uuid=$uuid
xe vm-start vm=$name
done
@rtomaszewski
rtomaszewski / isolated-network-vm.sh
Created May 19, 2014
create a vm on isolated network
View isolated-network-vm.sh
# (1)
$ xe vm-copy vm=vm-10 new-name-label=gateway-vm
$ xe network-list
$ xe vif-create network-uuid=b211707c-0f56-b33e-22b0-ad1816914b8a device=3 vm-uuid=4fb0febb-5659-f9b5-abf6-21cd63632c5b
$ xe vif-plug uuid=02600ba0-b040-733f-bcce-e64661dcb352
$ xe console vm=gateway-vm
# (2)
root@gateway-vm:/etc/network# cat interfaces
View xapi-demo.py
import XenAPI
s=XenAPI.Session('http://localhost/')
s.login_with_password('root', 'password')
s.xenapi.VM.get_all()
Out[30]:
['OpaqueRef:fed9f387-359c-5e34-04b3-7e9de0271e9b',
'OpaqueRef:f21c711b-5de7-fb1f-5320-ea4b8fbbdac2',
...
'OpaqueRef:0032adf3-04d3-6cf7-94fe-9d06af09bec7']