[Ovirt-devel] [PATCH node] Check to make sure a config file was applied, if not revert to default config

Perry Myers pmyers at redhat.com
Sun Sep 21 19:52:04 UTC 2008


ovirt-early tries to use the managed_node controller on the server
to get the remote config.  If there is none available a file is returned
but there is presently no way to determine if that file is 'empty' or not

This check looks to see if any ifup-eth* files were created.  If none were, then
we assume the config was blank and use the default bridge config of one bridge
per physical interface.

Also did some refactoring of log output for the configure network interfaces
function so that it's easier to see what it going on for debugging purposes.

Signed-off-by: Perry Myers <pmyers at redhat.com>
---
 scripts/ovirt-early     |   34 +++++++++++++++++++++++-----------
 scripts/ovirt-functions |    1 +
 2 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/scripts/ovirt-early b/scripts/ovirt-early
index 5843fed..3d2d0ca 100755
--- a/scripts/ovirt-early
+++ b/scripts/ovirt-early
@@ -21,38 +21,49 @@ get_mac_addresses() {
 configure_from_network() {
     DEVICE=$1
     if [ -n "$DEVICE" ]; then
-        printf .
+        echo "Configuring network Using interface $DEVICE"
         # setup temporary interface to retrieve configuration
         echo "network --device $DEVICE --bootproto dhcp" | nash
         if [ $? -eq 0 ]; then
-            printf .
             # 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"
             eval $(ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
             if [ "$status" = "0" ]; then
                 hostname $HOSTNAME
+                echo "Hostname resolved to $HOSTNAME"
                 # retrieve remote config
                 find_srv ovirt tcp
                 if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
-                    printf .
+                    echo "oVirt Server found at: $SRV_HOST:$SRV_PORT"
                     cfgdb=$(mktemp)
                     get_mac_addresses
-                    wget -q -O $cfgdb \
+                    echo "MACs to use: $macs"
+                    wget -O $cfgdb \
                       "http://$SRV_HOST:$SRV_PORT/ovirt/managed_node/config?host=$(hostname)&macs=$macs"
                     if [ $? -eq 0 ]; then
-                        printf .
+                        echo "Remote configuration bundle retrieved to $cfgdb"
                         bash $cfgdb
                         if [ -f /var/tmp/pre-config-script ]; then
-                            printf "loading kernel modules"
-                            bash /var/tmp/pre-config-script
+                            echo "Loading kernel modules"
+                            bash /var/tmp/pre-config-script \
+                                && echo "Kernel modules loaded" \
+                                || echo "Failed loading kernel modules"
                         fi
                         if [ -f /var/tmp/node-augtool ]; then
-                            augtool < /var/tmp/node-augtool
+                            echo "Loading remote config"
+                            augtool < /var/tmp/node-augtool \
+                                && echo "Remote config applied" \
+                                || echo "Failed applying remote config"
                         fi
-                        if [ $? -eq 0 ]; then
-                            printf "remote config applied."
+                        if ls /etc/sysconfig/network-scripts/ifcfg-eth* > /dev/null 2>&1; then
+                            echo "Network interfaces created from remote config"
                             return
+                        else
+                            echo "Remote config contained no network interfaces"
                         fi
+                    else
+                        echo "Failed to retrieve configuration bundle"
                     fi
                 fi
             fi
@@ -63,13 +74,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"
         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
-    printf "default config applied."
+    echo "Default config applied"
 }
 
 # find_disk $bus $serial $live_disk
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 792113a..68e9aa3 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -83,5 +83,6 @@ ovirt_store_config() {
            fi
        fi
     done
+    echo
     umount $ovirt && rmdir $ovirt
 }
-- 
1.5.5.1




More information about the ovirt-devel mailing list