[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [PATCH appliance] Fake Node creation now creates nodes with 128MB disk for use in testing



This allows easy testing of Node 'installation' and persistent config
data.

Signed-off-by: Perry Myers <pmyers redhat com>
---
 create-ovirt-appliance |   19 ++++++++++++++++---
 ovirt-appliance.spec   |    1 +
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/create-ovirt-appliance b/create-ovirt-appliance
index 071781a..c291041 100755
--- a/create-ovirt-appliance
+++ b/create-ovirt-appliance
@@ -14,6 +14,9 @@ NAME_DEFAULT=ovirt-appliance
 NET_SCRIPTS=/etc/sysconfig/network-scripts
 BRIDGENAME=ovirtbr0
 
+NODE_DISK_SIZE=128M
+NODE_DISK_FMT=raw
+
 imgdir=$IMGDIR_DEFAULT
 name=$NAME_DEFAULT
 
@@ -57,6 +60,7 @@ EOF
 
 gen_fake_managed_node() {
     local num=$1
+    local disk=$2
     local last_mac=$(( 54 + $num ))
 
     cat <<EOF
@@ -76,6 +80,10 @@ gen_fake_managed_node() {
   <on_crash>destroy</on_crash>
   <devices>
     <emulator>$KVM_BINARY</emulator>
+    <disk type='file' device='disk'>
+      <source file='$disk'/>
+      <target dev='hda'/>
+    </disk>
     <interface type='network'>
       <mac address='00:16:3e:12:34:$last_mac'/>
       <source network='$BRIDGENAME'/>
@@ -144,7 +152,7 @@ fi
 
 # now make sure the packages we need are installed
 if [ -e /etc/redhat-release ]; then
-    PACKAGES="libvirt kvm"
+    PACKAGES="libvirt kvm qemu-img"
     CHECK=$(rpm $(printf " -q %s " "$PACKAGES")  &> /dev/null; echo $?)
     KVM_BINARY=/usr/bin/qemu-kvm
 elif [ -e /etc/debian_version ]; then
@@ -199,12 +207,18 @@ if [ -n "$bridge" ]; then
         && die "$bridge device active with ip address, aborting!"
 fi
 
+mkdir -p $imgdir
+
 # define the fake managed nodes we will use.
 for i in `seq 3 5` ; do
+    imgname="node${i}.img"
+    if [ ! -f $imgdir/$imgname ]; then
+        qemu-img create -f $NODE_DISK_FMT $imgdir/$imgname $NODE_DISK_SIZE
+    fi
     virsh destroy node$i >& /dev/null
     virsh undefine node$i >& /dev/null
     TMPXML=$(mktemp)
-    gen_fake_managed_node $i > $TMPXML
+    gen_fake_managed_node $i $imgdir/$imgname > $TMPXML
     virsh define $TMPXML
     rm $TMPXML
 done
@@ -265,7 +279,6 @@ fi
     virsh undefine bundled
 } > /dev/null 2>&1
 
-mkdir -p $imgdir
 imgname=$name.img
 test ! -r $imgdir/$imgname && die "Disk image not found at $imgdir/$imgname"
 virsh destroy $name > /dev/null 2>&1
diff --git a/ovirt-appliance.spec b/ovirt-appliance.spec
index 52c248d..d2b29bb 100644
--- a/ovirt-appliance.spec
+++ b/ovirt-appliance.spec
@@ -25,6 +25,7 @@ BuildRequires: wget
 # is fixed, these Requires should be fixed.
 Requires: libvirt >= 0.4.4-2ovirt2
 Requires: kvm >= 72-3ovirt3
+Requires: qemu-img
 
 %define app_root %{_datadir}/%{name}
 
-- 
1.5.5.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]