Perry Myers
2009-Jan-20 03:01 UTC
[Ovirt-devel] [PATCH node-image] Enhancements to fake node creation script to assist with testing
Signed-off-by: Perry Myers <pmyers at redhat.com> --- create-ovirt-iso-nodes | 52 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 43 insertions(+), 9 deletions(-) diff --git a/create-ovirt-iso-nodes b/create-ovirt-iso-nodes index 80d6743..4d3876f 100755 --- a/create-ovirt-iso-nodes +++ b/create-ovirt-iso-nodes @@ -29,6 +29,10 @@ IMGDIR_DEFAULT=/var/lib/libvirt/images imgdir=$IMGDIR_DEFAULT NODEIMG_DEFAULT=/usr/share/ovirt-node-image/ovirt-node-image.iso nodeimg=$NODEIMG_DEFAULT +NUM_DISKS_DEFAULT=1 +RANGE_DEFAULT="6-9" +RAM_DEFAULT=512 +VCPUS_DEFAULT=1 NODE_DISK_FMT=qcow2 NODE_DISK_SIZE=6144M @@ -38,20 +42,31 @@ gen_fake_managed_node() { local nodeimg=$2 local last_mac=$(( 54 + $num )) + local os_variant=fedora10 + if [ "$no_virtio" = 1 ]; then + os_variant=fedora8 + fi + echo "Creating fake node$num using $nodeimg..." virsh destroy node$num > /dev/null 2>&1 virsh undefine node$num > /dev/null 2>&1 - rm -f $imgdir/node${i}-sda.$NODE_DISK_FMT - qemu-img create -f $NODE_DISK_FMT $imgdir/node${i}-sda.$NODE_DISK_FMT \ - $NODE_DISK_SIZE + + rm -f $imgdir/node${num}-* + + local disks+ for ((i=0;i<$num_disks;i+=1)); do + qemu-img create -f $NODE_DISK_FMT \ + $imgdir/node${num}-${i}.$NODE_DISK_FMT $NODE_DISK_SIZE + disks="$disks --disk path=$imgdir/node${num}-${i}.$NODE_DISK_FMT" + done + # FIXME: virt-install should be changed to have a --nostart parameter # that just defines the VM w/o starting it. - virt-install --name=node$num --ram=512 --vcpus=1 \ - --disk path=$imgdir/node${i}-sda.$NODE_DISK_FMT \ + virt-install --name=node$num --ram=$ram --vcpus=$vcpus $disks \ --cdrom=$nodeimg --livecd \ --network=bridge:$BRIDGENAME --mac=00:16:3e:12:34:$last_mac \ --vnc --accelerate --hvm --noautoconsole \ - --os-type=linux --os-variant=fedora10 \ + --os-type=linux --os-variant=$os_variant \ --force --noreboot virsh destroy node$num > /dev/null 2>&1 echo "node$num created" @@ -60,18 +75,34 @@ gen_fake_managed_node() { usage() { case $# in 1) warn "$1"; try_h; exit 1;; esac cat <<EOF -Usage: $ME [-d image_dir] [-n node.iso] +Usage: $ME [-d image_dir] [-n node.iso] [-c num_disks] [-s start-stop] + [-v vcpus] [-r ram] [-x] -n: node.iso to boot (default: $NODEIMG_DEFAULT) -d: directory to place virtual disk (default: $IMGDIR_DEFAULT) + -c: number of disks per fake node (default: $NUM_DISKS_DEFAULT) + -s: node range (default: $RANGE_DEFAULT) + -v: vcpus per node (default: $VCPUS_DEFAULT) + -r: ram in MB per node (default: $RAM_DEFAULT) + -x: toggle virtio devices off -h: display this help and exit EOF } err=0 help=0 -while getopts :d:n:h c; do +no_virtio=0 +num_disks=$NUM_DISKS_DEFAULT +range=$RANGE_DEFAULT +ram=$RAM_DEFAULT +vcpus=$VCPUS_DEFAULT +while getopts :d:n:s:c:v:r:xh c; do case $c in n) nodeimg=$OPTARG;; d) imgdir=$OPTARG;; + c) num_disks=$OPTARG;; + s) range=$OPTARG;; + v) vcpus=$OPTARG;; + r) ram=$OPTARG;; + x) no_virtio=1;; h) help=1;; '?') err=1; warn "invalid option: \`-$OPTARG'";; :) err=1; warn "missing argument to \`-$OPTARG' option";; @@ -92,6 +123,9 @@ test -f $nodeimg || die "could not find $nodeimg" cp $nodeimg $imgdir # define the fake managed nodes we will use. -for i in `seq 6 9` ; do +range_start=$(echo $range | cut -d '-' -f 1) +range_stop=$(echo $range | cut -d '-' -f 2) + +for i in `seq $range_start $range_stop` ; do gen_fake_managed_node $i $imgdir/$(basename $nodeimg) done -- 1.6.0.6