Skip to content

Commit

Permalink
Implement image device wipe for some VM's
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Oct 31, 2016
1 parent 44a9f6f commit e145bd8
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ run_rsync() {

wipe_build_environement() {
if test -n "$VM_TYPE"; then
vm_cleanup
vm_img_wipe
else
echo "Wiping build root: '$BUILD_ROOT'"

Expand Down
11 changes: 11 additions & 0 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,17 @@ vm_img_create() {
fi
}

vm_img_wipe() {
vm_wipe_$VM_TYPE "$@"

if test -n "$VM_IMAGE" -a ! -b "$VM_IMAGE" ; then
rm -f "$VM_IMAGE"
fi
if test -n "$VM_SWAP" -a ! -b "$VM_SWAP" ; then
rm -f "$VM_SWAP"
fi
}

vm_img_mkfs() {
local fs="$1"
local img="$2"
Expand Down
4 changes: 4 additions & 0 deletions build-vm-docker
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@ vm_cleanup_docker() {
:
}

vm_wipe_docker() {
local name="obsbuild.${BUILD_ROOT##*/}"
docker rm "$name" >/dev/null 2>&1 || true
}
5 changes: 5 additions & 0 deletions build-vm-ec2
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ cloud_volume_detach_ec2() {
return 0
}

vm_wipe_ec2() {
# not yet implemented
:
}

vm_verify_options_ec2() {
# verify settings
if test -z "$AWS_ACCESS_KEY" -o -z "$AWS_ACCESS_KEY" ; then
Expand Down
3 changes: 3 additions & 0 deletions build-vm-emulator
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ vm_detach_swap_emulator() {
vm_cleanup_emulator() {
:
}
vm_wipe_emulator() {
:
}

3 changes: 3 additions & 0 deletions build-vm-kvm
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,6 @@ vm_cleanup_kvm() {
:
}

vm_wipe_kvm() {
:
}
4 changes: 4 additions & 0 deletions build-vm-lxc
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ vm_detach_swap_lxc() {
:
}

vm_wipe_lxc() {
:
}

vm_cleanup_lxc() {
if test $$ -ne 1 && test $$ -ne 2 ; then
lxc_get_id
Expand Down
4 changes: 4 additions & 0 deletions build-vm-openstack
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ vm_fixup_openstack() {
chmod 0755 "$BUILD_ROOT/sbin/init"
}

vm_wipe_openstack() {
:
}

vm_kill_openstack() {
if nova show "$VM_VOLUME_NAME" >/dev/null 2>&1 ; then
if ! nova delete "$VM_VOLUME_NAME" ; then
Expand Down
4 changes: 4 additions & 0 deletions build-vm-pvm
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ vm_cleanup_pvm(){
pvm_deletelv $swaplv
}

vm_wipe_pvm(){
:
}

vm_fixup_pvm(){
VM_SWAPDEV=/dev/sdb
GRUBDIR=`mktemp -d /tmp/grubinstall.XXXX`
Expand Down
4 changes: 4 additions & 0 deletions build-vm-qemu
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ vm_cleanup_qemu() {
vm_cleanup_kvm
}

vm_wipe_qemu() {
:
}

4 changes: 4 additions & 0 deletions build-vm-uml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ vm_cleanup_uml() {
:
}

vm_wipe_uml() {
:
}

4 changes: 4 additions & 0 deletions build-vm-xen
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,7 @@ vm_cleanup_xen() {
:
}

vm_wipe_xen() {
:
}

3 changes: 3 additions & 0 deletions build-vm-zvm
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,6 @@ vm_cleanup_zvm() {
fi
}

vm_wipe_zvm() {
:
}

0 comments on commit e145bd8

Please sign in to comment.