[Ovirt-devel] [PATCH node] Enabled automated network configuration via kernel arguments.

Darryl L. Pierce dpierce at redhat.com
Tue Nov 18 16:12:41 UTC 2008


PUSH CANDIDATE: This patch has reworked so that it handles both automated and 
interactive scenarios. It also contains a fix for a weird situation where, during
interactive mode, the user could get into a state where they couldn't configure 
a device even after selecting it.

To invoke automatic network configuration, the user must specify the
interface to configure using the OVIRT_MGMT_IFACE kernel argument.
The value for this argument is the interface name for the network
device to be configured.

If supplied, the user can set the IP address, netmask and gateway for
this interface using the OVIRT_IP_ADDRESS, OVIRT_IP_NETMASK and
OVIRT_IP_GATEWAY respectively. If all of these options are not provided
then DHCP is assumed.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 scripts/ovirt-config-networking |   32 ++++++++++++++++++++++++--------
 1 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 4ad8af0..bfe35f2 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -3,6 +3,10 @@
 # Iterates over the list of network devices on the node and prompts the user
 # to configure each.
 
+ME=$(basename "$0")
+warn() { printf '%s: %s\n' "$ME" "$*" >&2; }
+die() { warn "$*"; exit 1; }
+
 WORKDIR=$(mktemp -d) || exit 1
 
 # Remove $WORKDIR upon interrupt (and HUP, PIPE, TERM) and upon normal
@@ -17,11 +21,16 @@ function configure_interface
 {
     NIC=$1
     AUTO=$2
-    IPADDR=$OVIRT_IP_ADDRESS
-    NETMASK=$OVIRT_IP_NETMASK
-    GATEWAY=$OVIRT_IP_GATEWAY
-
-    BRIDGE=ovirtbr`echo $NIC | cut -b4-`
+    if [[   "$AUTO" == "AUTO"    &&
+         -n "$OVIRT_IP_ADDRESS"  &&
+         -n "$OVIRT_IP_NETMASK"  &&
+         -n "$OVIRT_IP_GATEWAY" ]]; then
+        IPADDR=$OVIRT_IP_ADDRESS
+        NETMASK=$OVIRT_IP_NETMASK
+        GATEWAY=$OVIRT_IP_GATEWAY
+    fi
+
+    BRIDGE=ovirtbr$NIC
     IF_FILENAME="$WORKDIR/augtool-$NIC"
     BR_FILENAME="$WORKDIR/augtool-$BRIDGE"
 
@@ -40,6 +49,9 @@ function configure_interface
     # how do you want to configure this device? (dhcp, static IP)
     while true; do
         if [ -z "$AUTO" ]; then
+            IPADDR=
+            NETMASK=
+            GATEWAY=
             read -p "Will $BRIDGE use dynamic addressing? (Y/N) "
         else
             if [ -z "$IPADDR" ]; then
@@ -59,8 +71,11 @@ function configure_interface
                     printf "\t   Gateway: "; read; GATEWAY=$REPLY
 
                     printf "\nPlease review the details for $BRIDGE:\n"
-                    printf "\tIP Address: $IPADDR\n \t   Netmask: $NETMASK\n\t   Gateway: $GATEWAY\n"
-                    read -p "Is this correct? (Y/N) "
+                    printf '\t%s\n'\
+                           "IP Address: $IPADDR"\
+                           "   Netmask: $NETMASK"\
+                           "   Gateway: $GATEWAY"
+                    read -p "Is this correct? (Y/N/A) "
                 else
                     REPLY="Y"
                 fi
@@ -71,6 +86,7 @@ function configure_interface
                         BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/NETMASK $NETMASK"
                         break
                         ;;
+                    A|a) return ;;
                 esac
                 ;;
         esac
@@ -118,5 +134,5 @@ if [ "$RESTART" == "Y" ]; then
     { cat "$WORKDIR"/augtool-* && printf "save\n"; } > $config \
     && augtool < $config  \
     && service network restart
-    } >> $CONFIG_LOG_FILE 2>> $CONFIG_LOG_FILE
+    } >> $CONFIG_LOG_FILE 2>&1
 fi
-- 
1.5.6.5




More information about the ovirt-devel mailing list