[Ovirt-devel] [PATCH node] Replaced calls to echo with log so that we get datestamps in the log file

Perry Myers pmyers at redhat.com
Tue Jan 20 05:50:00 UTC 2009


Fix mount_config to only try to mount /config if the host has persistent
storage for Config defined.

Signed-off-by: Perry Myers <pmyers at redhat.com>
---
 scripts/ovirt           |   14 +++++++-------
 scripts/ovirt-early     |   26 +++++++++++++-------------
 scripts/ovirt-functions |   11 +++++++----
 scripts/ovirt-post      |    2 +-
 4 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/scripts/ovirt b/scripts/ovirt
index f789d24..8694db9 100755
--- a/scripts/ovirt
+++ b/scripts/ovirt
@@ -21,11 +21,11 @@ start() {
         wget -q \
             http://$SRV_HOST:$SRV_PORT/ipa/config/krb5.ini -O $krb5_conf.tmp
         if [ $? -ne 0 ]; then
-            echo "Failed to get $krb5_conf"; return 1
+            log "Failed to get $krb5_conf"; return 1
         fi
         mv $krb5_conf.tmp $krb5_conf
     else
-        echo "skipping Kerberos configuration"
+        log "skipping Kerberos configuration"
     fi
 
     find_srv identify tcp
@@ -37,10 +37,10 @@ start() {
         fi
         ovirt-awake start $SRV_HOST $SRV_PORT $krb5_tab
         if [ $? -ne 0 ]; then
-            echo "ovirt-awake failed"; return 1
+            log "ovirt-awake failed"; return 1
         fi
     else
-        echo "skipping ovirt-awake, oVirt identify service not available"
+        log "skipping ovirt-awake, oVirt identify service not available"
     fi
 
     find_srv collectd tcp
@@ -52,11 +52,11 @@ start() {
                 -e /<Plugin rrdtool>/,/<\/Plugin>/d $collectd_conf.in \
                 > $collectd_conf
             if [ $? -ne 0 ]; then
-                echo "Failed to write $collectd_conf"; return 1
+                log "Failed to write $collectd_conf"; return 1
             fi
         fi
     else
-        echo "skipping collectd configuration, collectd service not available"
+        log "skipping collectd configuration, collectd service not available"
     fi
 
     find_srv qpidd tcp
@@ -66,7 +66,7 @@ start() {
             echo "LIBVIRT_QPID_ARGS=\"--broker $SRV_HOST --port $SRV_PORT\"" >> $libvirt_qpid_conf
         fi
     else
-        echo "skipping libvirt-qpid configuration, could not find $libvirt_qpid_conf"
+        log "skipping libvirt-qpid configuration, could not find $libvirt_qpid_conf"
     fi
 }
 
diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index a7cf4dc..b99c26b 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -21,36 +21,36 @@ get_mac_addresses() {
 configure_from_network() {
     DEVICE=$1
     if [ -n "$DEVICE" ]; then
-        echo "Configuring network Using interface $DEVICE"
+        log "Configuring network Using interface $DEVICE"
         # setup temporary interface to retrieve configuration
         echo "network --device $DEVICE --bootproto dhcp" | nash
         if [ $? -eq 0 ]; then
             # from network-scripts/ifup-post
             IPADDR=$(LC_ALL=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }')
-            echo "Interface brought up with $IPADDR"
+            log "Interface brought up with $IPADDR"
             eval $(ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
             if [ "$status" = "0" ]; then
                 hostname $HOSTNAME
-                echo "Hostname resolved to $HOSTNAME"
+                log "Hostname resolved to $HOSTNAME"
                 # retrieve remote config
                 find_srv ovirt tcp
                 if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
-                    echo "oVirt Server found at: $SRV_HOST:$SRV_PORT"
+                    log "oVirt Server found at: $SRV_HOST:$SRV_PORT"
                     cfgdb=$(mktemp)
                     get_mac_addresses
-                    echo "MACs to use: $macs"
+                    log "MACs to use: $macs"
                     wget -O $cfgdb \
                       "http://$SRV_HOST:$SRV_PORT/ovirt/managed_node/config?host=$(hostname)&macs=$macs"
                     if [ $? -eq 0 ]; then
-                        echo "Remote configuration bundle retrieved to $cfgdb"
+                        log "Remote configuration bundle retrieved to $cfgdb"
                         ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG
 			if [ $? -eq 0 ]; then
-			    echo "Remote configuration retrieved and applied"
+			    log "Remote configuration retrieved and applied"
 			else
-			    echo "Failure to retrieve or apply remote configuration"
+			    log "Failure to retrieve or apply remote configuration"
 			fi
                     else
-                        echo "Failed to retrieve configuration bundle"
+                        log "Failed to retrieve configuration bundle"
                     fi
                     rm $cfgdb
                 fi
@@ -62,14 +62,14 @@ configure_from_network() {
     ETHDEVS=$(cd /sys/class/net && ls -d eth*)
     for eth in $ETHDEVS; do
         BRIDGE=ovirtbr`echo $eth | cut -b4-`
-        echo "Applying default configuration to $eth and $BRIDGE"
+        log "Applying default configuration to $eth and $BRIDGE"
         printf '%s\n' "DEVICE=$eth" ONBOOT=yes "BRIDGE=$BRIDGE" \
             > /etc/sysconfig/network-scripts/ifcfg-$eth
         printf '%s\n' "DEVICE=$BRIDGE" BOOTPROTO=dhcp \
             ONBOOT=yes TYPE=Bridge PEERNTP=yes DELAY=0 \
             > /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
     done
-    echo "Default config applied"
+    log "Default config applied"
 }
 
 # $(get_live_disk)
@@ -312,7 +312,7 @@ start() {
     params="bootif init vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size local_boot standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns syslog_server syslog_port collectd_server collectd_port bootparams hostname"
     mount_config
     if [ -e $OVIRT_DEFAULTS ]; then
-        echo "update ovirt defaults"
+        log "update ovirt defaults"
         tmpaug=$(mktemp)
         for p in $params; do
             PARAM=$(uc $p)
@@ -322,7 +322,7 @@ start() {
         done
         augtool $tmpaug
     else
-        echo "initial startup"
+        log "initial startup"
         # dump all ovirt bootparams
         mkdir -p $(dirname $OVIRT_DEFAULTS)
         echo > $OVIRT_DEFAULTS
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 7728640..8f1694b 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -219,12 +219,13 @@ mount_liveos() {
 # mount config partition
 # /config for persistance
 mount_config() {
-    if ! grep -q " /config " /proc/mounts; then
+    # Only try to mount /config if the persistent storage exists
+    if [ -e /dev/HostVG/Config ] ; then
         mkdir -p /config
-        mount /dev/HostVG/Config /config
-    fi
+        if ! grep -q "/dev/mapper/HostVG-Config " /proc/mounts; then
+            mount /dev/HostVG/Config /config || return 1
+        fi
 
-    if grep -q " /config " /proc/mounts; then
         # optional config embedded in the livecd image
         if [ -e /live/config ]; then
             cp -rv --update /live/config/* /config
@@ -241,6 +242,8 @@ mount_config() {
                 mount -n --bind $f "$target"
             fi
         done
+
+        return 0
     else
         # /config is not available
         return 1
diff --git a/scripts/ovirt-post b/scripts/ovirt-post
index 3861973..068c709 100755
--- a/scripts/ovirt-post
+++ b/scripts/ovirt-post
@@ -25,7 +25,7 @@ start() {
     if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
         ovirt-identify-node -s $SRV_HOST -p $SRV_PORT
     else
-        echo "skipping ovirt-identify-node, oVirt registration service not available"
+        log "skipping ovirt-identify-node, oVirt registration service not available"
     fi
 }
 
-- 
1.6.0.6




More information about the ovirt-devel mailing list