From c8a0789183a6384280e164ca0e1cd9bf136e5d52 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 30 Jan 2009 22:14:28 -0500 Subject: [PATCH] invirt-admin create-sysvm This produces a new sysvm with lvcreate, invirt-create-image, and writing out a Xen config file. invirt-admin will end up in a package, but which one I'm not sure, so for now it's on its own. Probably it should also end up being written in Python rather than shell. svn path=/trunk/scripts/invirt-admin/; revision=2040 --- invirt-admin | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100755 invirt-admin diff --git a/invirt-admin b/invirt-admin new file mode 100755 index 0000000..91c73c7 --- /dev/null +++ b/invirt-admin @@ -0,0 +1,76 @@ +#!/bin/bash + +set -e + +usage () { + echo "usage:" + echo "invirt-admin create-sysvm {options}" + echo " required options: --name, --fs-size, --swap-size, --memory," + echo " --hostname, --ip, --mac, --arch, --dist, --mirror" + echo + echo " fs-size, swap-size, memory in MB" + echo " fs-size + swap-size will be total disk-image size" + exit 2 +} + +if [ create-sysvm != "$1" ]; then + usage +fi +shift + +vg=xenvg +while [ $# -gt 0 ]; do + case "$1" in + --vg) vg=$2; shift 2;; + --name) name=$2; shift 2;; + --fs-size) fs_size=$2; shift 2;; + --swap-size) swap_size=$2; shift 2;; + --memory) memory=$2; shift 2;; + --hostname) hostname=$2; shift 2;; + --ip) ip=$2; shift 2;; + --mac) mac=$2; shift 2;; + --arch) arch=$2; shift 2;; + --dist) dist=$2; shift 2;; + --mirror) mirror=$2; shift 2;; + esac +done +if [ -z "$name" ]; then + usage +fi +disk_size=$(( $fs_size + $swap_size )) + + +lvcreate "$vg" --name "s_${name}_hda" --size "$disk_size"m + +# XXX breaks if $name has dashes +TARGET=/dev/mapper/$vg-s_${name}_hda FSSIZE=$fs_size \ +ARCH=$arch DIST=$dist MIRROR=$mirror \ +HOSTNAME=$hostname IP=$ip \ + invirt-create-image + +cat >/etc/xen/sysvms/s_$name <