[Ovirt-devel] [PATCH] Makes the managed node boot up process more generic.
Joey Boggs
jboggs at redhat.com
Fri Feb 12 20:14:26 UTC 2010
On 02/10/2010 05:09 PM, Darryl L. Pierce wrote:
> Refactored the sysvinit scripts so that developers can insert their own
> startup code into the boot process.
>
> Added a new system configuration file, /etc/sysconfig/node-config.
>
> Added /etc/node.d/ to allow developers to add scripts to be executed
> during the startup process.
>
> Signed-off-by: Darryl L. Pierce<dpierce at redhat.com>
> ---
> Makefile.am | 1 +
> ovirt-node.spec.in | 12 +++-
> scripts/node-config | 15 ++++
> scripts/ovirt | 49 ++++++++---
> scripts/ovirt-awake | 152 +++++++++++++++++++++++------------
> scripts/ovirt-config-boot-wrapper | 4 +-
> scripts/ovirt-early | 159 ++++++++++++++++++-------------------
> scripts/ovirt-functions | 2 +
> scripts/ovirt-post | 83 +++++++++++--------
> 9 files changed, 294 insertions(+), 183 deletions(-)
> create mode 100644 scripts/node-config
> mode change 100644 => 100755 scripts/ovirt-awake
>
> diff --git a/Makefile.am b/Makefile.am
> index 2f8865d..7798d09 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -69,6 +69,7 @@ EXTRA_DIST = \
> nodeadmin/utils.py \
> nodeadmin/volumeconfig.py \
> scripts/collectd.conf.in \
> + scripts/node-config \
> scripts/ovirt \
> scripts/ovirt-awake \
> scripts/ovirt-config-boot \
> diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
> index c3da1a0..3d8d100 100644
> --- a/ovirt-node.spec.in
> +++ b/ovirt-node.spec.in
> @@ -1,5 +1,6 @@
> %define product_family oVirt Node
> %define beta Beta
> +%define mgmt_scripts_dir %{_sysconfdir}/node.d
> %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
>
>
> @@ -87,6 +88,8 @@ make install DESTDIR=%{buildroot}
> %{__install} -d -m0755 %{buildroot}%{_sbindir}
> %{__install} -d -m0755 %{buildroot}%{_sysconfdir}
> %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/chkconfig.d
> +%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/sysconfig
> +%{__install} -d -m0755 %{buildroot}%{mgmt_scripts_dir}
> %{__install} -d -m0755 %{buildroot}%{_initrddir}
> %{__install} -d -m0755 %{buildroot}%{app_root}
> %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/cron.d
> @@ -94,7 +97,7 @@ make install DESTDIR=%{buildroot}
> %{__install} -d -m0755 %{buildroot}%{_sysconfdir}/logrotate.d
> %{__install} -d -m0755 %{buildroot}%{python_sitelib}/nodeadmin
>
> -%{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
> +%{__install} -p -m0644 scripts/node-config %{buildroot}%{_sysconfdir}/sysconfig
> %{__install} -p -m0755 scripts/ovirt-config-boot %{buildroot}%{_sbindir}
> %{__install} -p -m0755 scripts/ovirt-config-boot-wrapper %{buildroot}%{_sbindir}
> %{__install} -p -m0755 scripts/ovirt-config-collectd %{buildroot}%{_sbindir}
> @@ -153,6 +156,7 @@ make install DESTDIR=%{buildroot}
> # in Makefile now
>
> %{__install} -p -m0755 scripts/ovirt-functions %{buildroot}%{_initrddir}
> +%{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_initrddir}
> %{__install} -p -m0755 scripts/ovirt-early %{buildroot}%{_initrddir}
> %{__install} -p -m0755 scripts/ovirt-firstboot %{buildroot}%{_initrddir}
> %{__install} -p -m0755 scripts/ovirt %{buildroot}%{_initrddir}
> @@ -227,6 +231,7 @@ ln -s ovirt-release %{buildroot}/etc/system-release
> %post
> # Setup basic collectd configuration
> sed '/<Plugin network>/,/<\/Plugin>/d' /etc/collectd.conf.in> /etc/collectd.conf
> +/sbin/chkconfig --add ovirt-awake
> /sbin/chkconfig --add ovirt-early
> /sbin/chkconfig --add ovirt-firstboot
> /sbin/chkconfig --add ovirt
> @@ -238,6 +243,7 @@ if [ $1 = 0 ] ; then
> /sbin/service ovirt-firstboor stop>/dev/null 2>&1
> /sbin/service ovirt stop>/dev/null 2>&1
> /sbin/service ovirt-post stop>/dev/null 2>&1
> + /sbin/chkconfig --del ovirt-awake
> /sbin/chkconfig --del ovirt-early
> /sbin/chkconfig --del ovirt-firstboot
> /sbin/chkconfig --del ovirt
> @@ -270,9 +276,11 @@ fi
> %config(noreplace) %{_sysconfdir}/logrotate.d/ovirt-node
> %config(noreplace) %{_sysconfdir}/cron.d/ovirt-logrotate
>
> +%{mgmt_scripts_dir}
> %{_sysconfdir}/ovirt-config-boot.d
> %{_sysconfdir}/ovirt-config-setup.d
> %config(noreplace) %{_sysconfdir}/collectd.conf.in
> +%config(noreplace) %{_sysconfdir}/sysconfig/node-config
>
> %doc COPYING
> # should be ifarch i386
> @@ -280,7 +288,6 @@ fi
> # end i386 bits
> %{app_root}/syslinux-vesa-splash.jpg
>
> -%{_sbindir}/ovirt-awake
> %{_sbindir}/ovirt-config-boot
> %{_sbindir}/ovirt-config-boot-wrapper
> %{_sbindir}/ovirt-config-collectd
> @@ -300,6 +307,7 @@ fi
> %{_sbindir}/persist
> %{_sbindir}/unpersist
>
> +%{_initrddir}/ovirt-awake
> %{_initrddir}/ovirt-early
> %{_initrddir}/ovirt-firstboot
> %{_initrddir}/ovirt
> diff --git a/scripts/node-config b/scripts/node-config
> new file mode 100644
> index 0000000..47d42a1
> --- /dev/null
> +++ b/scripts/node-config
> @@ -0,0 +1,15 @@
> +# node configuration
> +
> +# defines the node's runtime mode, unless overridden
> +# on the kernel command line
> +# allowed values are:
> +# ovirt - managed by an oVirt management server
> +# none - standalone, unmamanged mode
> +# managed - managed by another server type
> +OVIRT_RUNTIME_MODE="none"
> +
> +# the management server hostname or address
> +OVIRT_MANAGEMENT_SERVER=""
> +
> +# the maangement server port
> +OVIRT_MANAGEMENT_PORT=""
> \ No newline at end of file
> diff --git a/scripts/ovirt b/scripts/ovirt
> index 3a03460..d8d52cc 100755
> --- a/scripts/ovirt
> +++ b/scripts/ovirt
> @@ -2,21 +2,24 @@
> #
> # ovirt Start ovirt services
> #
> -# chkconfig: - 11 99
> -# description: ovirt services
> -#
> +### BEGIN INIT INFO
> +# Provides: ovirt
> +# Required-Start: ovirt-early
> +# Default-Start: 2 3 4 5
> +# Description: Performs managed node configuration functions.
> +### END INIT INFO
>
> # Source functions library
> . /etc/init.d/functions
> . /etc/init.d/ovirt-functions
>
> prog=ovirt
> -lockfile=/var/lock/subsys/$prog
> -
> -start() {
> +VAR_SUBSYS_OVIRT=/var/lock/subsys/$prog
>
> - touch $lockfile
> +# load the configuration file
> +[ -f "$NODE_CONFIG" ]&& . "$NODE_CONFIG"
>
> +ovirt_start() {
> if is_standalone; then
> return 0
> fi
> @@ -72,7 +75,7 @@ start() {
> echo "LIBVIRT_QPID_ARGS=\"--broker $SRV_HOST --port $SRV_PORT\"">> $libvirt_qpid_conf
> echo "/usr/kerberos/bin/kinit -k -t /etc/libvirt/krb5.tab qpidd/`hostname`">> $libvirt_qpid_conf
> fi
> - matahari_conf=/etc/sysconfig/matahari
> + matahari_conf=/etc/sysconfig/matahari
> if [ -f $matahari_conf ]; then
> echo "MATAHARI_ARGS=\"--broker $SRV_HOST --port $SRV_PORT\"">> $matahari_conf
> echo "/usr/kerberos/bin/kinit -k -t /etc/libvirt/krb5.tab qpidd/`hostname`">> $matahari_conf
> @@ -80,22 +83,42 @@ start() {
> else
> log "skipping libvirt-qpid and matahari configuration, could not find $libvirt_qpid_conf"
> fi
> +}
> +
> +start() {
> + touch $VAR_SUBSYS_OVIRT
> + case $OVIRT_RUNTIME_MODE in
> + "ovirt")
> + ovirt_start
> + ;;
> + "managed")
> + if [ -x $MANAGEMENT_SCRIPTS_DIR/ready ]; then
> + log "Executing $MANAGEMENT_SCRIPTS_DIR/ready."
> + $MANAGEMENT_SCRIPTS_DIR/ready
> + RC=$?
> + else
> + log "No script to perform node activation."
> + fi
> + esac
> + rm -f $VAR_SUBSYS_OVIRT
> + return $RC
> +}
>
> - rm -f $lockfile
> +stop() {
> + echo -n "Stopping ovirt: "
> + success
> }
>
> case "$1" in
> start)
> - printf "Starting ovirt: "
> -
> + [ -f "$VAR_SUBSYS_OVIRT" ]&& exit 0
> + echo -n "Starting ovirt: "
> {
> log "Starting ovirt"
> start
> log "Completed ovirt"
> }>> $OVIRT_LOGFILE 2>&1
> -
> test $? == 0&& success || failure
> - echo
> ;;
> status)
> status $prog
> diff --git a/scripts/ovirt-awake b/scripts/ovirt-awake
> old mode 100644
> new mode 100755
> index 336c2b1..55db140
> --- a/scripts/ovirt-awake
> +++ b/scripts/ovirt-awake
> @@ -1,9 +1,8 @@
> #!/bin/bash
> #
> -# ovirt-awake Notifies the oVirt server that an oVirt Node is
> -# starting up.
> +# ovirt-awake - Notifies any management server that the node is starting.
> #
> -# Copyright (C) 2008 Red Hat, Inc.
> +# Copyright (C) 2008-2010 Red Hat, Inc.
> # Written by Darryl L. Pierce<dpierce at redhat.com>
> #
> # This program is free software; you can redistribute it and/or modify
> @@ -20,86 +19,135 @@
> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> # MA 02110-1301, USA. A copy of the GNU General Public License is
> # also available at http://www.gnu.org/copyleft/gpl.html.
> +#
> +### BEGIN INIT INFO
> +# Provides: ovirt-awake
> +# Default-Start: 2 3 4 5
> +# Description: Managed node service to alert management servers.
> +### END INIT INFO
> +
> +# Source functions library
> +# config: /etc/sysconfig/node-config
>
> -# Source function library
> . /etc/init.d/functions
> . /etc/init.d/ovirt-functions
>
> -function connect-to-server () {
> - echo "Connecting to $SRV_HOST:$SRV_PORT"
> - exec 3<> /dev/tcp/$SRV_HOST/$SRV_PORT
> -}
> +prog=ovirt-early
> +NODE_CONFIG=/etc/sysconfig/node-config
> +VAR_SUBSYS_NODECONFIG=/var/lock/subsys/node-config
>
> -function disconnect-from-server () {
> -<&3-
> -}
> +# load the configuration file
> +[ -f "$NODE_CONFIG" ]&& . "$NODE_CONFIG"
>
> -function send-text () {
> - echo "$1" 1>&3
> -}
> +send_text () {
> + local text=${1}
>
> -function receive-text () {
> - read 0<&3
> + echo "$text" 1>&3
> }
>
> -function error () {
> - errmsg="ERR: (ovirt-awake) $1"
> - send-text "$errmsg"
> - log "$errmsg"
> +receive_text () {
> + read 0<&3
> }
>
> -start () {
> - connect-to-server
> -
> - receive-text
> -
> - if [ $REPLY == "HELLO?" ]; then
> - echo "Starting wakeup conversation."
> +error () {
> + local text=${1-}
>
> - send-text "HELLO!"
> -
> - read 0<&3
> -
> - if [ $REPLY == "MODE?" ]; then
> - send-text "AWAKEN"
> -
> - receive-text
> + send_text "ERR: (ovirt-awake) ${text}"
> + # log "${text}"
> +}
>
> - KEYTAB=`echo $REPLY | awk '{ print $2 }'`
> +ovirt_startup () {
> + local mgmthost=${OVIRT_MANAGEMENT_SERVER}
> + local mgmtport=${OVIRT_MANAGEMENT_PORT}
>
> - if [ -n "$KEYTAB" -a -n "$KEYTAB_FILE" ]; then
> - echo "Retrieving keytab: '$KEYTAB'"
> + if [[ -z "${mgmthost}" ]] || [[ -z "${mgmtport}" ]]; then
> + find_srv identify tcp
> + mgmthost=$SRV_HOST
> + mgmtport=$SRV_PORT
> + fi
>
> - wget -q "$KEYTAB" --no-check-certificate --output-document="$KEYTAB_FILE"
> + if [[ -n "${mgmthost}" ]]&& [[ -n "${mgmtport}" ]]; then
> + # log "Notifying oVirt management server: ${mgmthost}:${mgmtport}"
> + exec 3<> /dev/tcp/$mgmthost:$mgmtport
> +
> + connect-to-server
> + receive_text
> + if [ $REPLY == "HELLO?" ]; then
> + logo "Starting wakeup conversation."
> + send_text "HELLO!"
> + receive_text
> + if [ $REPLY == "MODE?" ]; then
> + send_text "AWAKEN"
> + receive_text
> + KEYTAB=$(echo $REPLY | awk '{ print $2 }')
> + if [ -n "$KEYTAB" -a -n "$KEYTAB_FILE" ]; then
> + # log "Retrieving keytab: '$KEYTAB'"
> + wget -q "$KEYTAB" --no-check-certificate --output-document="$KEYTAB_FILE"
> + else
> + log "No keytab to retrieve"
> + fi
> + send_text ACK
> else
> - echo "No keytab to retrieve"
> + error "Did not get a mode request."
> fi
> - send-text ACK
> else
> - error "Did not get a mode request."
> + error "Did not get a proper startup marker."
> fi
> + # log "Disconnecting."
> +<&3-
> else
> - error "Did not get a proper startup marker."
> + # log "Missing server information. Failing..."
> + return 1
> fi
> +}
>
> - echo "Disconnecting."
> +# Override this method to provide support for notifying a management
> +# system that the node has started and will be available after
> +# system initialization
> +start () {
> + local RC=0
> +
> + touch $VAR_SUBSYS_NODECONFIG
> + # log "Starting ovirt-awake."
> + case "$OVIRT_RUNTIME_MODE" in
> + "none")
> + log "Node is operating in unmanaged mode."
> + ;;
> + "ovirt")
> + ovirt_startup
> + RC=$?
> + ;;
> + "managed")
> + if [ -x /config/$MANAGEMENT_SCRIPTS_DIR/awake ]; then
> + log "Executing /config/$MANAGEMENT_SCRIPTS_DIR/awake"
> + /config/$MANAGEMENT_SCRIPTS_DIR/awake
> + else
> + echo "No script found to notify management server during awake state."
> + fi
> + ;;
> + esac
>
> - disconnect-from-server
> + # log "Completed ovirt-awake: RC=${RC}"
> + rm -f $VAR_SUBSYS_NODECONFIG
> + return $RC
> }
>
> case "$1" in
> start)
> - SRV_HOST=$2
> - SRV_PORT=$3
> - KEYTAB_FILE=$4
> - start
> - RETVAL=$?
> - ;;
> + echo -n "Starting ovirt-awake: "
> + [ -f "$VAR_SUBSYS_NODECONFIG" ]&& exit 0
> + {
> + start
> + RETVAL=$?
> + log "Completed ovirt-awake: RETVAL=$?"
> + }>> $OVIRT_LOGFILE 2>&1
> + test $RETVAL == 0&& success || failure
> + ;;
>
> *)
> echo "Usage: $0 start"
> RETVAL=2
> - ;;
> + ;;
> esac
>
> exit $RETVAL
> diff --git a/scripts/ovirt-config-boot-wrapper b/scripts/ovirt-config-boot-wrapper
> index 06f1088..89f0fc0 100755
> --- a/scripts/ovirt-config-boot-wrapper
> +++ b/scripts/ovirt-config-boot-wrapper
> @@ -20,9 +20,9 @@ continuing."
> printf "\n"
> read -p "Please enter kernel boot arguments (hit return to use the above): "
> if [[ -n "$REPLY" ]]; then
> - bootparams="${REPLY}"
> + bootparams="${REPLY}"
> else
> - bootparams="${OVIRT_BOOTPARAMS}"
> + bootparams="${OVIRT_BOOTPARAMS}"
> fi
> if ask_yes_or_no "Do you wish to continue ([Y]es/[N]o)?"; then
> mount_live \
> diff --git a/scripts/ovirt-early b/scripts/ovirt-early
> index 0689bdb..23c4f6e 100755
> --- a/scripts/ovirt-early
> +++ b/scripts/ovirt-early
> @@ -2,16 +2,22 @@
> #
> # ovirt-early Start early ovirt services
> #
> -# chkconfig: - 01 99
> -# description: ovirt-early services
> -#
> +### BEGIN INIT INFO
> +# Provides: ovirt-early
> +# Required-Start: ovirt-awake
> +# Default-Start: 2 3 4 5
> +# Dewscription: Managed node early configuration service
> +### END INIT INFO
>
> # Source functions library
> . /etc/init.d/functions
> . /etc/init.d/ovirt-functions
>
> prog=ovirt-early
> -lockfile=/var/lock/subsys/$prog
> +VAR_SUBSYS_OVIRT_EARLY=/var/lock/subsys/$prog
> +
> +# load the configuration file
> +[ -f "$NODE_CONFIG" ]&& . "$NODE_CONFIG"
>
> BONDING_MODCONF_FILE=/etc/modprobe.d/bonding
> AUGTOOL_CONFIG=/var/tmp/augtool-config
> @@ -23,16 +29,16 @@ get_mac_addresses() {
> macs=""
> devices=$(ls -b /sys/class/net/)
> for device in $devices; do
> - if [ "$device" != "$DEVICE" ]; then
> - mac=$(cat /sys/class/net/$device/address 2>/dev/null)
> - if [ -n "$mac" -a "$mac" != "00:00:00:00:00:00" ]; then
> - macs="${macs}${mac}=${device},"
> - fi
> - fi
> + if [ "$device" != "$DEVICE" ]; then
> + mac=$(cat /sys/class/net/$device/address 2>/dev/null)
> + if [ -n "$mac" -a "$mac" != "00:00:00:00:00:00" ]; then
> + macs="${macs}${mac}=${device},"
> + fi
> + fi
> done
> }
>
> -configure_from_network() {
> +configure_ovirt_management_nic() {
> DEVICE=$1
>
> if [ -n "$DEVICE" ]; then
> @@ -62,12 +68,12 @@ configure_from_network() {
> if [ $? -eq 0 ]; then
> log "Remote configuration bundle retrieved to $cfgdb"
> ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG
> - if [ $? -eq 0 ]; then
> - log "Remote configuration retrieved and applied"
> + if [ $? -eq 0 ]; then
> + log "Remote configuration retrieved and applied"
> rm $cfgdb
> - else
> - log "Failure to retrieve or apply remote configuration"
> - fi
> + else
> + log "Failure to retrieve or apply remote configuration"
> + fi
> else
> log "Failed to retrieve configuration bundle"
> fi
> @@ -88,11 +94,11 @@ configure_from_network() {
> if [ ! -f $ifcfg ]; then
> log "Applying default configuration to $DEVICE and $BRIDGE"
> printf '%s\n' "DEVICE=$DEVICE" ONBOOT=yes "BRIDGE=$BRIDGE" \
> - > /etc/sysconfig/network-scripts/ifcfg-$DEVICE
> +> /etc/sysconfig/network-scripts/ifcfg-$DEVICE
> printf '%s\n' "DEVICE=$BRIDGE" "BOOTPROTO=dhcp" \
> - ONBOOT=yes TYPE=Bridge PEERNTP=yes DELAY=0 \
> - > /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
> - log "Default config applied"
> + ONBOOT=yes TYPE=Bridge PEERNTP=yes DELAY=0 \
> +> /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
> + log "Default config applied"
> fi
> }
>
> @@ -135,9 +141,39 @@ find_disk() {
> return 1
> }
>
> +configure_management_interface() {
> + log "Configuring the manangement interface."
> + case $OVIRT_RUNTIME_MODE in
> + "ovirt")
> + configure_ovirt_management_nic $bootif
> + if [ -n "$init" ]; then
> + ovirt-config-storage AUTO
> + # initial configuration storage, after /config creation
> + ovirt_store_config \
> + /etc/sysconfig/network-scripts/ifcfg-* \
> + $BONDING_MODCONF_FILE
> + if [ $upgrade = 1 ]; then
> + # local disk installation for managed mode
> + mount_live
> + ovirt-config-boot /live "$bootparams"
> + fi
> + fi
> + ;;
> + "managed")
> + if [ -x $MANAGEMENT_SCRIPTS_DIR/configure-management-interface ]; then
> + log "Executing $MANAGEMENT_SCRIPTS_DIR/configure-management-interface"
> + $MANAGEMENT_SCRIPTS_DIR/configure-management-interface
> + else
> + echo "No script to configure management interface found."
> + fi
> + ;;
> + "none")
> + log "Unmanaged node: no management interface to configure."
> + esac
> +}
>
> start() {
> - touch $lockfile
> + touch $VAR_SUBSYS_OVIRT_EARLY
> # oVirt boot parameters
> # BOOTIF=link|eth*|<MAC> (appended by pxelinux)
> # ovirt_init=[usb|scsi[:serial#]|/dev/...]
> @@ -351,21 +387,21 @@ start() {
> dns=*)
> dns=${i#dns=}
> ;;
> - ntp=*)
> - ntp=${i#ntp=}
> - ;;
> + ntp=*)
> + ntp=${i#ntp=}
> + ;;
> hostname=*)
> hostname=${i#hostname=}
> ;;
> vlan=*)
> vlan=${i#vlan=}
> ;;
> - ssh_pwauth=1 | ssh_pwauth=true)
> - ssh_pwauth=true
> - ;;
> - ssh_pwauth=0 | ssh_pwauth=false)
> - ssh_pwauth=false
> - ;;
> + ssh_pwauth=1 | ssh_pwauth=true)
> + ssh_pwauth=true
> + ;;
> + ssh_pwauth=0 | ssh_pwauth=false)
> + ssh_pwauth=false
> + ;;
> syslog=*)
> i=${i#syslog=}
> eval $(printf $i|awk -F: '{print "syslog_server="$1; print "syslog_port="$2;}')
> @@ -438,22 +474,10 @@ start() {
> -e "s/^mech_list: .*gssapi.*/mech_list: digest-md5/" \
> /etc/sasl2/libvirt.conf
> else
> - configure_from_network $bootif
> - if [ -n "$init" ]; then
> - ovirt-config-storage AUTO
> - # initial configuration storage, after /config creation
> - ovirt_store_config \
> - /etc/sysconfig/network-scripts/ifcfg-* \
> - $BONDING_MODCONF_FILE
> - if [ $upgrade = 1 ]; then
> - # local disk installation for managed mode
> - mount_live
> - ovirt-config-boot /live "$bootparams"
> - fi
> - fi
> + configure_manament_interface
> fi
>
> - rm -f $lockfile
> + rm -f $VAR_SUBSYS_OVIRT_EARLY
>
> for hook in $ovirt_early; do
> post="$EARLY_DIR/post-$hook"
> @@ -465,49 +489,22 @@ start() {
> return 0
> }
>
> -scan_for_swap() {
> - # swap partition activation
> - # find all of the partitions on the system
> -
> - # get the system pagesize
> - PAGESIZE=`getconf PAGESIZE`
> -
> - # look first at raw partitions XXX disk/by-id or HAL? (for cciss)
> - BLOCKDEVS=`ls /dev/sd? /dev/hd? 2>/dev/null`
> -
> - # now LVM partitions
> - LVMDEVS="$DEVICES `lvscan | awk '{print $2}' | tr -d \"'\"`"
> -
> - SWAPDEVS="$LVMDEVS"
> - for dev in $BLOCKDEVS; do
> - SWAPDEVS="$SWAPDEVS `fdisk -l $dev 2>/dev/null | tr '*' ' ' \
> - | awk '$5 ~ /82/ {print $1}'`"
> - done
> -
> - # now check if any of these partitions are swap, and activate if so
> - for device in $SWAPDEVS; do
> - sig=`dd if=$device bs=1 count=10 skip=$(( $PAGESIZE - 10 )) \
> - 2>/dev/null`
> - if [ "$sig" = "SWAPSPACE2" ]; then
> - swapon $device
> - fi
> - done
> +stop() {
> + echo -n "Stopping ovirt-early: "
> + success
> }
>
> case "$1" in
> start)
> - printf "Starting ovirt-early: "
> -
> + [ -f "$VAR_SUBSYS_NODE_CONFIG" ]&& exit 0
> + echo -n "Starting ovirt-early: "
> {
> - start_log
> log "Starting ovirt-early"
> start
> log "Completed ovirt-early"
> - stop_log
> - }
> -
> - test $? == 0&& success || failure
> - echo
> + RETVAL=$?
> + }>> $OVIRT_LOGFILE 2>&1
> + test $RETVAL == 0&& success || failure
> ;;
> status)
> status $prog
> @@ -521,5 +518,7 @@ case "$1" in
> ;;
> *)
> echo "Usage: ovirt-early {start}"
> - exit 2
> + RETVAL=2
> esac
> +
> +exit $RETVAL
> diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
> index bab194b..ff2b016 100644
> --- a/scripts/ovirt-functions
> +++ b/scripts/ovirt-functions
> @@ -16,6 +16,8 @@ OVIRT_STANDALONE=${OVIRT_STANDALONE:-0}
>
> OVIRT_BACKUP_DIR=/var/lib/ovirt-backup
>
> +MANAGEMENT_SCRIPTS_DIR=/etc/node.d
> +
> OVIRT_CONFIG_FILES="\
> /etc/sysconfig/network-scripts/ifcfg-* \
> /etc/rsyslog.conf \
> diff --git a/scripts/ovirt-post b/scripts/ovirt-post
> index 03363cc..951d108 100755
> --- a/scripts/ovirt-post
> +++ b/scripts/ovirt-post
> @@ -2,34 +2,40 @@
> #
> # ovirt Start ovirt services
> #
> -# chkconfig: - 98 02
> -# description: ovirt-post services
> -#
> +### BEGIN INIT INFO
> +# Provides: ovirt-post
> +# Required-Start: ovirt
> +# Default-Start: 2 3 4 5
> +# Description: Performs managed node post configuration setup.
> +### END INIT INFO
>
> # Source functions library
> . /etc/init.d/functions
> . /etc/init.d/ovirt-functions
>
> prog=ovirt-post
> -lockfile=/var/lock/subsys/$prog
> +VAR_SUBSYS_OVIRT_POST=/var/lock/subsys/$prog
> +
> +# load the configuration file
> +[ -f "$NODE_CONFIG" ]&& . "$NODE_CONFIG"
>
> start() {
> # wait for libvirt to finish initializing
> local count=0
> while true; do
> - if [ -r /var/run/libvirt/libvirt-sock ]; then
> - break
> - elif [ "$count" == "100" ]; then
> - log "Libvirt did not initialize in time..."
> - return 1
> - else
> - log "Waiting for libvirt to finish initializing..."
> - count=$(expr $count + 1)
> - sleep 1
> - fi
> -
> - touch $lockfile
> -
> + if [ -r /var/run/libvirt/libvirt-sock ]; then
> + break
> + elif [ "$count" == "100" ]; then
> + log "Libvirt did not initialize in time..."
> + return 1
> + else
> + log "Waiting for libvirt to finish initializing..."
> + count=$(expr $count + 1)
> + sleep 1
> + fi
> +
> + touch $VAR_SUBSYS_OVIRT_POST
> +
> done
> BACKUP=$(mktemp)
> ISSUE=/etc/issue
> @@ -38,20 +44,20 @@ start() {
> cp -f $BACKUP $ISSUE
> hwvirt=$(virsh capabilities)
> if [[ $hwvirt =~ kvm ]]; then
> - log "Hardware virtualization detected"
> + log "Hardware virtualization detected"
> else
> - log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
> - log "!!! Hardware Virtualization Is Unavailable !!!"
> - log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
> -
> - echo "Virtualization hardware is unavailable.">> $ISSUE
> -
> - flags=$(cat /proc/cpuinfo | grep "^flags")
> - if [[ $flags =~ vmx ]] || [[ $flags =~ svm ]]; then
> - echo "(Virtualization hardware was detected but is disabled)">> $ISSUE
> - else
> - echo "(No virtualization hardware was detected on this system)">> $ISSUE
> - fi
> + log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
> + log "!!! Hardware Virtualization Is Unavailable !!!"
> + log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
> +
> + echo "Virtualization hardware is unavailable.">> $ISSUE
> +
> + flags=$(cat /proc/cpuinfo | grep "^flags")
> + if [[ $flags =~ vmx ]] || [[ $flags =~ svm ]]; then
> + echo "(Virtualization hardware was detected but is disabled)">> $ISSUE
> + else
> + echo "(No virtualization hardware was detected on this system)">> $ISSUE
> + fi
> fi
> cp -f $ISSUE $ISSUE_NET
>
> @@ -62,18 +68,27 @@ start() {
> # persist selected configuration files
> ovirt_store_config \
> /etc/krb5.conf \
> + /etc/node.d \
> + /etc/sysconfig/node-config
> /etc/libvirt/krb5.tab \
> /etc/ssh/ssh_host*_key*
>
> - # Removed ovirt-identify-node since it has now
> - # been replaced with the matahari qmf agent.
> + # perform any post startup operations
> + case $OVIRT_RUNTIME_MODE in
> + esac
> +
> + rm -f $VAR_SUBSYS_OVIRT_POST
> +}
>
> - rm -f $lockfile
> +stop() {
> + echo -n "Stopping ovirt-post: "
> + success
> }
>
> case "$1" in
> start)
> - printf "Starting ovirt-post: "
> + [ -f "$VAR_SUBSYS_OVIRT_POST" ]&& exit 0
> + echo -n "Starting ovirt-post: "
>
> {
> log "Starting ovirt-post"
>
looks sane to me and still boots normal so... ACK
More information about the ovirt-devel
mailing list