Skip to content

Instantly share code, notes, and snippets.

View fabiand's full-sized avatar

Fabian Deutsch fabiand

View GitHub Profile
NODEISO=$1
IMGBASEIMG=$2
in_node() {
guestfish --ro -a $NODEISO run : mount /dev/sda1 / : mount-loop /LiveOS/squashfs.img /isolinux : mount-loop /isolinux/LiveOS/ext3fs.img / : sh "$@" ;
}
in_imgbased() {
guestfish --ro -a $IMGBASEIMG run : mount /dev/HostVG/Image-0.0 / : sh "$@" ;
}
docker-pid() { docker inspect --format="{{.State.Pid}}" $1 ; }
DSTCT=${1}
DSTPID=$(docker-pid $DSTCT)
UNCONNECTEDETH=$(nmcli -t -f device,type,connection device | egrep "ethernet:--$" | cut -d ":" -f1)
for NIC in $UNCONNECTEDETH
do
echo "Moving '$NIC' to netns of '$DSTPID'"
@contextmanager
def download_iso(w):
# do download
yield path_to_w
# do removal
with downloaded_iso("centos") as isopath:
# do stuff
##### THIS IS EQUAL TO
@fabiand
fabiand / guestfish-ova.sh
Last active January 6, 2016 09:52
Convenience script to modify the qcow image inside an RHEV OVA using guestfish
#!/usr/bin/bash
err() { echo "ERROR $@" >&2 ; }
info() { echo "INFO $@" ; }
usage() { echo -e "Usage: $0 OVAFILENAME [<guestfish arguments>]\nExtracts the given OVA, runs guestfish on the image, and creates an OVA again after quitting guestfish." ; }
[[ ! -f "$1" ]] && { usage ; exit 1 ; }
@fabiand
fabiand / test-yum-check-update.sh
Created July 29, 2016 13:13
Test case to showcase that check-update does not see an update, but update then performs one
set -ex
export LC_ALL=C
TOPDIR=$PWD/rpms
ROOT=$PWD/root
REPO="$TOPDIR"
setup() {
rm -rf "$TOPDIR" "$ROOT"
set -ex
export LC_ALL=C
TOPDIR=$PWD/rpms
ROOT=$PWD/root
REPO="$TOPDIR"
setup() {
rm -rf "$TOPDIR" "$ROOT"
@fabiand
fabiand / net.yaml
Last active February 16, 2017 11:46
Story:
After a class is declared, a Network object can be created, which is getting
associated to such a class. The network object itself contains the logical
netowkr informations - eventually even IPAM needs to be discussed.
An interface on a VM is getting connected to a network.
---
kind: Network
metadata:

Keybase proof

I hereby claim:

  • I am fabiand on github.
  • I am fabiand (https://keybase.io/fabiand) on keybase.
  • I have a public key ASDFpvAiVJbqU0BD9fd2yA7RA-IdHOT8bLf4OA_WQaQe3go

To claim this, I am signing this object:

Definition

$ cat vm.yaml

kind: VirtualMachine
metadata:
  name: barbar
spec:
  state: down
@fabiand
fabiand / qemu-pod.yaml
Last active November 17, 2017 12:20
Connecting qemu to the pod's network
apiVersioin: v1
kind: Pod
metadata:
name: qemu
spec:
securityContext:
runAsUser: 0
volumes:
- name: host-dev
hostPath: