[Ovirt-devel] [PATCH appliance] Fake Node creation now creates nodes with 128MB disk for use in testing
Perry Myers
pmyers at redhat.com
Mon Sep 15 20:25:21 UTC 2008
This allows easy testing of Node 'installation' and persistent config
data. Includes suggestions by Alan Pevec for making the spec file
portable between Fedora and RHEL based systems by removing
Requires: qemu-img and replacing with Requires: /usr/bin/qemu-img
Also removes the PACKAGES check for Red Hat/Fedora systems since
these checks are handled by the RPM deps.
Signed-off-by: Perry Myers <pmyers at redhat.com>
---
create-ovirt-appliance | 21 +++++++++++++++++----
ovirt-appliance.spec | 1 +
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/create-ovirt-appliance b/create-ovirt-appliance
index 071781a..773d4d6 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,8 +152,8 @@ fi
# now make sure the packages we need are installed
if [ -e /etc/redhat-release ]; then
- PACKAGES="libvirt kvm"
- CHECK=$(rpm $(printf " -q %s " "$PACKAGES") &> /dev/null; echo $?)
+ # We rely on RPM deps for this in Red Hat/Fedora systems
+ CHECK=0
KVM_BINARY=/usr/bin/qemu-kvm
elif [ -e /etc/debian_version ]; then
# Works in Ubuntu 8.04. Still needs testing in Debian
@@ -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..bd32391 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: /usr/bin/qemu-img
%define app_root %{_datadir}/%{name}
--
1.5.5.1
More information about the ovirt-devel
mailing list