summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcreate-vm11
-rwxr-xr-xremove-vm10
2 files changed, 10 insertions, 11 deletions
diff --git a/create-vm b/create-vm
index afe8b71..92bd0ee 100755
--- a/create-vm
+++ b/create-vm
@@ -2,6 +2,7 @@
#
# Create a new VM for liw.
+
set -eu
@@ -24,8 +25,8 @@ fi
name="$1"
base="$2"
-# Where are the base images?
-imagedir="/big/base-images"
+# Config variables.
+. "$HOME/.config/ansibleness/vm.conf"
# Does the base image exist?
basepath="$imagedir/base-$base.img.xz"
@@ -38,9 +39,6 @@ fi
# How large are the (uncompressed) images?
size="4G"
-# What volume group should we use?
-vg="exolobe1-vg"
-
# Create new LV.
sudo lvcreate --name "$name" --size "$size" "$vg"
lvpath="/dev/$vg/$name"
@@ -64,7 +62,8 @@ virt-install --connect qemu:///system \
--noautoconsole
# Get the MAC address.
-mac="$(virsh dumpxml "$name" | sed -n "/<mac address=/s/^.*'\(.*\)'.*/\1/p")"
+mac="$(virsh -c qemu:///system dumpxml "$name" |
+ sed -n "/<mac address=/s/^.*'\(.*\)'.*/\1/p")"
# Get IP address related to the MAC address. Append that to /etc/hosts.
leases=/var/lib/libvirt/dnsmasq/default.leases
diff --git a/remove-vm b/remove-vm
index 680bef4..363f2a0 100755
--- a/remove-vm
+++ b/remove-vm
@@ -7,14 +7,14 @@ set -eu
# Command line parameters.
name="$1"
-# What volume group should we use?
-vg="exolobe1-vg"
+# Read config variables.
+. "$HOME/.config/ansibleness/vm.conf"
# Shut down and remove the VM, if it exists.
-if virsh list --all | grep -F "$name" > /dev/null
+if virsh -c qemu:///system list --all | grep -F "$name" > /dev/null
then
- virsh destroy "$name" || true
- virsh undefine "$name"
+ virsh -c qemu:///system destroy "$name" || true
+ virsh -c qemu:///system undefine "$name"
fi
# Remove the LV, if it exists.