[Ovirt-devel] [PATCH] replace virt-install with appliance-creator in create-wui-appliance.sh
Alan Pevec
apevec at redhat.com
Wed Jul 23 23:54:12 UTC 2008
- use plain partitions in kickstart disk layout
- use sparse files for iSCSI backing store (can't create LVMs on kpartx mappings)
- add serial console to domain XML
- option to produce qcow2 compressed image
ovirt.org repo contains appliance-tools-002-1.fc9
which works with unmodified livecd-tools-017.1-1.fc9
Signed-off-by: Alan Pevec <apevec at redhat.com>
---
build-all.sh | 23 ++-----
wui-appliance/common-install.ks | 8 +--
wui-appliance/common-pkgs.ks | 5 +-
wui-appliance/create-wui-appliance.sh | 118 ++++++++++++++-------------------
wui-appliance/wui-devel.ks | 46 +++++++------
5 files changed, 87 insertions(+), 113 deletions(-)
diff --git a/build-all.sh b/build-all.sh
index 26d6009..5819d37 100755
--- a/build-all.sh
+++ b/build-all.sh
@@ -35,7 +35,7 @@ Usage: $ME [-w] [-n] [-p init|update] [-s] [-a] [-c] [-v git|release|none] [-e e
-p: update pungi repository (init or update)
-s: include SRPMs and produce source ISO
-a: updates all (WUI, Node, Appliance)
- -c: cleanup old repos (pungi and ovirt)
+ -c: cleanup local repos (pungi and ovirt)
-v: update version type (git, release, none) default is git
-e: ethernet device to use as bridge (i.e. eth1)
-h: display this help and exit
@@ -65,10 +65,10 @@ while getopts wnp:sahcv:e: c; do
n) update_node=1;;
p) update_pungi=$OPTARG;;
s) include_src=1;;
- a) update_wui=1; update_node=1; update_app=1; update_pungi=init;;
+ a) update_wui=1; update_node=1; update_app=1;;
c) cleanup=1;;
- e) bridge=$OPTARG;;
v) version_type=$OPTARG;;
+ e) bridge=$OPTARG;;
h) help=1;;
'?') err=1; warn "invalid option: \`-$OPTARG'";;
:) err=1; warn "missing argument to \`-$OPTARG' option";;
@@ -234,23 +234,17 @@ EOF
fi
# build oVirt admin appliance
-# NOTE: create-wui-appliance.sh must be run as root
if [ $update_app == 1 ]; then
- # FIXME: This can go away once we have livecd tools building the appliances
- VIRBR=$(virsh net-dumpxml default \
- | sed -n "s/^ *<ip address='\([^']*\)' .*/\1/p")
- test -z $VIRBR && die "Could not get ip address of default network for app"
-
cd $BASE/wui-appliance
make clean
cat > repos.ks << EOF
-url --url http://$VIRBR/pungi/$F_REL/$ARCH/os
+url --url http://localhost/pungi/$F_REL/$ARCH/os
EOF
excludepkgs=
if [[ -f $OVIRT/repodata/repomd.xml ]]; then
excludepkgs='--excludepkgs=ovirt*'
cat >> repos.ks << EOF
-repo --name=ovirt --baseurl=http://$VIRBR/ovirt
+repo --name=ovirt --baseurl=http://localhost/ovirt
EOF
fi
cat >> repos.ks << EOF
@@ -258,7 +252,6 @@ repo --name=ovirt-org --baseurl=http://ovirt.org/repos/ovirt/$F_REL/$ARCH $exclu
EOF
make
- cp wui-rel.ks $OVIRT
bridge_flag=
if [ -n "$bridge" ]; then
@@ -266,11 +259,7 @@ EOF
fi
./create-wui-appliance.sh \
- -t http://$VIRBR/pungi/$F_REL/$ARCH/os \
- -k http://$VIRBR/ovirt/wui-rel.ks \
+ -k wui-rel.ks \
$bridge_flag
- set +x
- echo "oVirt appliance setup started, check progress with:"
- echo -n " virt-viewer ovirt-appliance"
fi
diff --git a/wui-appliance/common-install.ks b/wui-appliance/common-install.ks
index 36eb28d..c9cbb0a 100644
--- a/wui-appliance/common-install.ks
+++ b/wui-appliance/common-install.ks
@@ -16,9 +16,7 @@ bootloader --location=mbr --driveorder=sda
# not guaranteed to work
zerombr
clearpart --all --drives=sda
-part /boot --fstype ext3 --size=100 --ondisk=sda
-part pv.2 --size=1 --grow --ondisk=sda
-volgroup VolGroup00 --pesize=32768 pv.2
-logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512
-logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow
+part /boot --ondisk=sda --fstype=ext3 --size=100
+part / --ondisk=sda --fstype=ext3 --size=5000
+part swap --ondisk=sda --fstype=swap --size=512
reboot
diff --git a/wui-appliance/common-pkgs.ks b/wui-appliance/common-pkgs.ks
index 34546a7..7a8866c 100644
--- a/wui-appliance/common-pkgs.ks
+++ b/wui-appliance/common-pkgs.ks
@@ -1,4 +1,5 @@
@core
+kernel
cronie
policycoreutils
chkconfig
@@ -19,6 +20,8 @@ firefox
gtk-vnc-plugin
xorg-x11-xauth
virt-viewer
+rhpl
cobbler
bind-utils
-
+augeas
+/usr/sbin/lokkit
diff --git a/wui-appliance/create-wui-appliance.sh b/wui-appliance/create-wui-appliance.sh
index d77ba16..2a3eb3c 100755
--- a/wui-appliance/create-wui-appliance.sh
+++ b/wui-appliance/create-wui-appliance.sh
@@ -11,40 +11,31 @@ IMGSIZE=6000M
ISO=
IMGDIR_DEFAULT=/var/lib/libvirt/images
NET_SCRIPTS=/etc/sysconfig/network-scripts
-ARCH_DEFAULT=$(uname -m)
NAME=ovirt-appliance
BRIDGENAME=ovirtbr
-ARCH=$ARCH_DEFAULT
IMGDIR=$IMGDIR_DEFAULT
-CONSOLE_FLAG=--noautoconsole
usage() {
case $# in 1) warn "$1"; try_h; exit 1;; esac
cat <<EOF
-Usage: $ME [-i install_iso | -t install_tree] [-d image_dir] [-a x86_64|i686] [-k kickstart] [-e eth]
- -i: location of installation ISO
- -t: location of installation tree
- -k: URL of kickstart file for use with installation tree
- -o: Display virt-viewer window during install (implied by -i option)
+Usage: $ME [-c] [-d image_dir] [-k kickstart] [-e eth]
-d: directory to place virtual disk (default: $IMGDIR_DEFAULT)
- -a: architecture for the virtual machine (default: $ARCH_DEFAULT)
+ -c: compress the image (qcow2 compressed)
+ -k: appliance kickstart file
-e: ethernet device to use as bridge (i.e. eth1)
-h: display this help and exit
EOF
}
err=0 help=0
-viewer=0
+compress=0
bridge=
-while getopts :a:d:i:t:k:ohe: c; do
+while getopts :d:k:he: c; do
case $c in
- i) ISO=$OPTARG;;
- t) TREE=$OPTARG;;
- k) KICKSTART=$OPTARG;;
d) IMGDIR=$OPTARG;;
- a) ARCH=$OPTARG;;
- o) CONSOLE_FLAG=;;
+ c) compress=1;;
+ k) KICKSTART=$OPTARG;;
e) bridge=$OPTARG;;
h) help=1;;
'?') err=1; warn "invalid option: \`-$OPTARG'";;
@@ -55,36 +46,6 @@ done
test $err = 1 && { try_h; exit 1; }
test $help = 1 && { usage; exit 0; }
-test -n "$ISO" -a -n "$TREE" && usage "Can only specify one of -i and -t"
-
-if [ -n "$ISO" ]; then
- test -n "$KICKSTART" && usage "-k not valid in conjunction with -i"
- test -r "$ISO" || usage "missing or unreadable ISO file: \`$ISO'"
- cdrom_arg="-c $ISO"
- # If we're installing from an ISO, we need console to provide kickstart
- CONSOLE_FLAG=
- do_install=1
-elif [ -n "$TREE" ]; then
- location_arg="-l $TREE"
- do_install=1
-else
- do_install=0
-fi
-
-if [ -n "$KICKSTART" ]; then
- extra_flag=-x
- extra_arg="ksdevice=eth0 ks=$KICKSTART"
-else
- # If we didn't provide a kickstart, we need console access to provide
- # one at boot time
- CONSOLE_FLAG=
-fi
-
-case $ARCH in
- i686|x86_64);;
- *) usage "invalid architecture: \`$ARCH'";;
-esac
-
gen_bridge() {
name=$1
cat << EOF
@@ -121,6 +82,12 @@ gen_fake_managed_node() {
<mac address='00:16:3e:12:34:$last_mac'/>
<source network='$BRIDGENAME'/>
</interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' listen='127.0.0.1'/>
</devices>
@@ -158,6 +125,12 @@ gen_app() {
<interface type='network'>
<source network='$BRIDGENAME'/>
</interface>
+ <serial type='pty'>
+ <target port='0'/>
+ </serial>
+ <console type='pty'>
+ <target port='0'/>
+ </console>
<input type='mouse' bus='ps2'/>
<graphics type='vnc' port='-1' listen='127.0.0.1'/>
</devices>
@@ -241,11 +214,11 @@ done
virsh net-dumpxml $BRIDGENAME >& /dev/null
RETVAL=$?
if [ $( brctl show | grep -c $BRIDGENAME ) -ne 0 -a $RETVAL -ne 0 ]; then
- # in this case, the bridge exists, but isn't managed by libvirt
- # abort, since the user will have to clean up themselves
- echo "Bridge $BRIDGENAME already exists. Please make sure you"
- echo "unconfigure $BRIDGENAME, and then try the command again"
- exit 1
+ # in this case, the bridge exists, but isn't managed by libvirt
+ # abort, since the user will have to clean up themselves
+ echo "Bridge $BRIDGENAME already exists. Please make sure you"
+ echo "unconfigure $BRIDGENAME, and then try the command again"
+ exit 1
fi
# Remove old bridge device if it exists
@@ -258,8 +231,6 @@ if [ -n "$old_bridge" ]; then
brctl delif $BRIDGENAME $old_bridge
fi
-# TODO when virFileReadAll is fixed for stdin
-#virsh net-define <(gen_dummy)
virsh net-destroy $BRIDGENAME > /dev/null 2>&1
virsh net-undefine $BRIDGENAME > /dev/null 2>&1
TMPXML=$(mktemp) || exit 1
@@ -300,20 +271,29 @@ mkdir -p $IMGDIR
virsh destroy $NAME > /dev/null 2>&1
virsh undefine $NAME > /dev/null 2>&1
-if [ $do_install = 1 ]; then
- rm -f "$IMGDIR/$IMGNAME"
- qemu-img create -f qcow2 "$IMGDIR/$IMGNAME" $IMGSIZE
- virt-install -n $NAME -r $RAM -f "$IMGDIR/$IMGNAME" --vnc \
- --accelerate -v --os-type=linux --arch=$ARCH \
- -w network:default -w network:$BRIDGENAME \
- $location_arg $cdrom_arg $extra_flag "$extra_arg" --noacpi $CONSOLE_FLAG
-else
- test ! -r $IMGDIR/$IMGNAME && die "Disk image not found at $IMGDIR/$IMGNAME"
-
- TMPXML=$(mktemp) || exit 1
- gen_app $IMGDIR/$IMGNAME $RAM > $TMPXML
- virsh define $TMPXML
- rm $TMPXML
- echo "Application defined using disk located at $IMGDIR/$IMGNAME."
- echo "Run virsh start $NAME to start the appliance"
+if [ -n "$KICKSTART" ]; then
+ mkdir -p tmp
+ appliance-creator --config $KICKSTART --name $NAME --tmpdir $(pwd)/tmp
+ # FIXME add --compress option to appliance-creator
+ if [ $compress -ne 0 ]; then
+ echo -n "Compressing the image..."
+ qemu-img convert -c $NAME-sda.raw -O qcow2 "$IMGDIR/$IMGNAME"
+ rm ovirt-appliance-sda.raw
+ echo "done"
+ else
+ echo -n "Moving the image..."
+ mv ovirt-appliance-sda.raw "$IMGDIR/$IMGNAME"
+ restorecon -v "$IMGDIR/$IMGNAME"
+ echo "done"
+ fi
fi
+
+test ! -r $IMGDIR/$IMGNAME && die "Disk image not found at $IMGDIR/$IMGNAME"
+
+TMPXML=$(mktemp) || exit 1
+# FIXME virt-image to define the appliance instance
+gen_app $IMGDIR/$IMGNAME $RAM > $TMPXML
+virsh define $TMPXML
+rm $TMPXML
+echo "Application defined using disk located at $IMGDIR/$IMGNAME."
+echo "Run virsh start $NAME to start the appliance"
diff --git a/wui-appliance/wui-devel.ks b/wui-appliance/wui-devel.ks
index 2903a19..e36f3a7 100644
--- a/wui-appliance/wui-devel.ks
+++ b/wui-appliance/wui-devel.ks
@@ -2,12 +2,7 @@ install
%include common-install.ks
-network --device=eth1 --bootproto=static --ip=192.168.50.2 --netmask=255.255.255.0 --onboot=on --nameserver=192.168.50.2
-
-# Create some fake iSCSI partitions
-logvol /iscsi3 --name=iSCSI3 --vgname=VolGroup00 --size=64
-logvol /iscsi4 --name=iSCSI4 --vgname=VolGroup00 --size=64
-logvol /iscsi5 --name=iSCSI5 --vgname=VolGroup00 --size=64
+network --device=eth1 --bootproto=static --ip=192.168.50.2 --netmask=255.255.255.0 --onboot=on --nameserver=192.168.50.2 --hostname=management.priv.ovirt.org
%include repos.ks
@@ -20,12 +15,19 @@ exec > /root/kickstart-post.log 2>&1
%include common-post.ks
-# make sure our "hostname" resolves to management.priv.ovirt.org
-sed -i -e 's/^HOSTNAME.*/HOSTNAME=management.priv.ovirt.org/' \
- /etc/sysconfig/network
+# FIXME [PATCH] fix SelinuxConfig firewall side-effect
+lokkit -f --nostart --disabled
+# FIXME imgcreate.kickstart.NetworkConfig doesn't store nameserver into ifcfg-*
+# only in resolv.conf which gets overwritten by dhclient-script
+augtool <<EOF
+set /files/etc/sysconfig/network-scripts/ifcfg-eth0/PEERDNS no
+set /files/etc/sysconfig/network-scripts/ifcfg-eth1/DNS1 192.168.50.2
+save
+EOF
# make sure to update the /etc/hosts with the list of all possible DHCP
# addresses we can hand out; dnsmasq uses this
+sed -i -e 's/management\.priv\.ovirt\.org//' /etc/hosts
echo "192.168.50.2 management.priv.ovirt.org" >> /etc/hosts
for i in `seq 3 252` ; do
echo "192.168.50.$i node$i.priv.ovirt.org" >> /etc/hosts
@@ -75,9 +77,11 @@ IsRelative=1
Path=$ff_profile_dir
EOF
-# make sure we don't mount the "fake" iSCSI LUNs, since they are meant to
-# be exported
-sed -i -e '/\/dev\/VolGroup00\/iSCSI[0-9].*/d' /etc/fstab
+# Create sparse files for iSCSI backing stores
+mkdir -p /ovirtiscsi
+for i in `seq 3 5`; do
+ dd if=/dev/null of=/ovirtiscsi/iSCSI$i bs=1 count=1 seek=64M
+done
# make an NFS directory with some small, fake disks and export them via NFS
# to show off the NFS part of the WUI
@@ -193,7 +197,7 @@ cat > /etc/init.d/ovirt-wui-dev << \EOF
#
# ovirt-wui-dev oVirt WUI Dev appliance service
#
-# chkconfig: 3 60 40
+# chkconfig: 3 60 40
# description: ovirt dev wui appliance service
#
@@ -215,22 +219,22 @@ start() {
-O option:router,192.168.50.2 -O option:ntp-server,192.168.50.2 \
--dhcp-option=12 \
-R --local /priv.ovirt.org/ --server 192.168.122.1
-
+
# Set up the fake iscsi target
tgtadm --lld iscsi --op new --mode target --tid 1 \
-T ovirtpriv:storage
-
+
+ #
+ # Now associate them to the backing stores
#
- # Now associate them to the LVs
- #
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
- --lun 1 -b /dev/VolGroup00/iSCSI3
+ --lun 1 -b /ovirtiscsi/iSCSI3
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
- --lun 2 -b /dev/VolGroup00/iSCSI4
+ --lun 2 -b /ovirtiscsi/iSCSI4
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 \
- --lun 3 -b /dev/VolGroup00/iSCSI5
+ --lun 3 -b /ovirtiscsi/iSCSI5
- #
+ #
# Now make them available
#
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL
--
1.5.5.1
More information about the ovirt-devel
mailing list