[Ovirt-devel] [PATCH node] separate ovirt-config-boot for in-place image upgrades

Alan Pevec apevec at redhat.com
Thu Dec 11 16:16:53 UTC 2008


---
 Makefile.am               |    1 +
 ovirt-node.spec.in        |    6 ++
 scripts/ovirt-config-boot |  116 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+), 0 deletions(-)
 create mode 100755 scripts/ovirt-config-boot

diff --git a/Makefile.am b/Makefile.am
index 9b54ae6..c5829f3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -27,6 +27,7 @@ EXTRA_DIST =			\
   scripts/collectd.conf.in	\
   scripts/ovirt			\
   scripts/ovirt-awake		\
+  scripts/ovirt-config-boot  \
   scripts/ovirt-config-logging  \
   scripts/ovirt-config-networking \
   scripts/ovirt-config-password \
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index ef65bf0..0973af9 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -35,6 +35,7 @@ Requires:       bind-utils
 # qemu-img RPM.
 Requires:       qemu-img
 Requires:       nc
+Requires:       grub
 Requires:       /usr/sbin/crond
 ExclusiveArch:  %{ix86} x86_64
 
@@ -87,6 +88,7 @@ cd -
 %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/logrotate.d
 
 %{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
+%{__install} -p -m0755 scripts/ovirt-config-boot %{buildroot}%{_sbindir}
 %{__install} -p -m0755 scripts/ovirt-config-logging %{buildroot}%{_sbindir}
 %{__install} -p -m0755 scripts/ovirt-config-networking %{buildroot}%{_sbindir}
 %{__install} -p -m0755 scripts/ovirt-config-password %{buildroot}%{_sbindir}
@@ -171,6 +173,7 @@ fi
 %files
 %defattr(-,root,root,0755)
 %{_sbindir}/ovirt-awake
+%{_sbindir}/ovirt-config-boot
 %{_sbindir}/ovirt-config-logging
 %{_sbindir}/ovirt-config-networking
 %{_sbindir}/ovirt-config-password
@@ -200,6 +203,9 @@ fi
 %doc ovirt-identify-node/COPYING
 
 %changelog
+* Wed Dec 10 2008 Alan Pevec <apevec at redhat.com> 0.96-0.1
+- ovirt-config-* setup scripts for standalone mode
+
 * Thu Sep 11 2008 Chris Lalancette <clalance at redhat.com> - 0.92 0.7
 - Add the ovirt-install- and ovirt-uninstall-node scripts, and refactor
   post to accomodate
diff --git a/scripts/ovirt-config-boot b/scripts/ovirt-config-boot
new file mode 100755
index 0000000..f535620
--- /dev/null
+++ b/scripts/ovirt-config-boot
@@ -0,0 +1,116 @@
+#!/bin/bash
+#
+# ovirt-config-boot - configure local boot disk partition
+
+# SYNOPSIS
+# ovirt-config-boot livecd_path bootparams
+#
+#       boot_disk   - boot disk device e.g. /dev/sda
+#
+#       livecd_path - where livecd media is mounted,
+#                     parent of LiveOS and isolinux folders
+#
+#       bootparams  - extra boot parameters like console=...
+#
+
+# Source functions library
+. /etc/init.d/functions
+. /etc/init.d/ovirt-functions
+
+
+# local_boot_install livecd_path bootparams
+#  livecd_path -livecd media
+#  bootparams - extra boot parameters like console=...
+#
+#  copy oVirt Node image to the local LVM /dev/HostVG
+ovirt_boot_setup() {
+    local disk=$1
+    local live=$2
+    local bootparams=$3
+    printf "installing oVirt Node image ..."
+    mount_boot
+    mount_liveos
+    # install oVirt Node image for local boot
+    if [ -e "$live/syslinux" ]; then
+      syslinux=syslinux
+    elif [ -e "$live/isolinux" ]; then
+      syslinux=isolinux
+    else
+      syslinux=
+    fi
+    rm -rf /boot/grub
+    rm -rf /liveos/LiveOS
+    mkdir -p /boot/grub
+    mkdir -p /liveos/LiveOS
+    cp -p $live/LiveOS/squashfs.img /liveos/LiveOS \
+    && cp -p $live/$syslinux/vmlinuz0 /boot
+    rc=$?
+    if [ $rc -ne 0 ]; then
+      printf "image copy failed\n"
+      return $rc
+    fi
+    # append LVM support to the livecd initramfs
+    tmpdir=$(mktemp -d)
+    cd $tmpdir
+    gzip -dc $live/$syslinux/initrd0.img | cpio -id init sbin/real-init
+    init_script=init
+    if [ -e sbin/real-init ]; then
+        # Fedora mkliveinitrd
+        init_script=sbin/real-init
+    fi
+    sed -i '/^\/sbin\/udev.*settle/ a \echo Scanning logical volumes\
+lvm vgscan --ignorelockingfailure\
+echo Activating logical volumes\
+lvm vgchange -ay --ignorelockingfailure HostVG \
+' $init_script
+    mkdir -p bin
+    bit=
+    if [ -e /lib64 ]; then
+        bit=64
+    fi
+    mkdir -p lib$bit
+    if [ -e /sbin/lvm.static ]; then
+        cp /sbin/lvm.static bin/lvm
+    else
+        cp /sbin/lvm bin
+        # lvm is not static in Fedora
+        cp /lib$bit/libreadline.so.5 /lib$bit/libncurses.so.5 lib$bit
+    fi
+    ( printf "$init_script\nbin\nlib$bit" | cpio -H newc --quiet -o ) |
+      gzip -9 |
+      cat $live/$syslinux/initrd0.img - > /boot/initrd0.img
+
+    cat > /boot/grub/grub.conf << EOF
+default=0
+timeout=5
+hiddenmenu
+title oVirt Node
+    root (hd0,0)
+    kernel /vmlinuz0 ro root=/dev/HostVG/Root roottypefs=ext3 liveimg $bootparams
+    initrd /initrd0.img
+EOF
+    echo "(hd0) $disk" > /boot/grub/device.map
+    ( cd /usr/share/grub/*; cp -p stage? e2fs_stage1_5 /boot/grub )
+    grub --device-map=/boot/grub/device.map > /dev/null <<EOF
+root (hd0,0)
+setup --prefix=/grub (hd0)
+EOF
+    rc=$?
+    if [ $rc -ne 0 ]; then
+        printf "boot loader install failed\n"
+        return $rc
+    fi
+    # remove unused 1.5 stages
+    find /boot/grub -name '*_stage1_5' ! -name e2fs_stage1_5 \
+        -exec rm {} \;
+    # avoid reboot loops using Cobbler PXE only once
+    # Cobbler XMLRPC post-install trigger (XXX is there cobbler SRV record?):
+    # wget "http://192.168.50.2/cblr/svc/op/trig/mode/post/system/$(hostname)"
+    #   -O /dev/null
+    sync; sync; sync
+    # caller decides when to reboot
+}
+
+
+ovirt_boot_setup $1 $2 $3
+
-- 
1.6.0.4




More information about the ovirt-devel mailing list