[Ovirt-devel] [PATCH ovirt-node] standalone mode - configure networking

Alan Pevec apevec at redhat.com
Fri Nov 7 01:27:44 UTC 2008


From: Darryl L. Pierce <dpierce at redhat.com>

---
 scripts/ovirt-config-networking |   97 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 8b13789..705521b 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -1 +1,98 @@
+#!/bin/bash
+#
+# Iterates over the list of network devices on the node and prompts the user
+# to configure each.
 
+CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg"
+
+function configure_interface
+{
+    NIC=$1
+    FILENAME="/var/tmp/augtool-$NIC"
+
+    printf "\nCONFIGURE INTERFACE: $NIC\n\n"
+
+    THIS_ROOT="$CONFIG_FILE_ROOT-$NIC"
+    CONFIG="rm $THIS_ROOT\nset $THIS_ROOT/DEVICE $NIC"
+
+    # Is this NIC shared?
+    while true; do
+        printf "Is $NIC a shared interface? (Y/N) "
+        read
+        case $REPLY in
+            Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/TYPE bridge"; break ;;
+            N|n) bridge="N"; break ;;
+        esac
+    done
+
+    # how do you want to configure this device? (dhcp, static IP)
+    while true; do
+        printf "Does $NIC use dynamic addressing? (Y/N) "
+        read
+        case $REPLY in
+            Y|y) CONFIG="$CONFIG\nset $THIS_ROOT/BOOTPROTO dhcp"; break ;;
+            N|n)
+                printf "\tIP Address: "; read; IPADDR=$REPLY
+                printf "\t   Netmask: "; read; NETMASK=$REPLY
+                printf "\t Broadcast: "; read; BROADCAST=$REPLY
+                printf "\t   Gateway: "; read; GATEWAY=$REPLY
+
+                printf "\nIP Address: $IPADDR\nNetmask: $NETMASK\nBroadcast: $BROADCAST\nGateway: $GATEWAY\n"
+                printf "Is this correct? (Y/N) "
+                read
+                case $REPLY in
+                    Y|y)
+                        CONFIG="$CONFIG\nset $THIS_ROOT/IPADDR $IPADDR"
+                        CONFIG="$CONFIG\nset $THIS_ROOT/BROADCAST $BROADCAST"
+                        CONFIG="$CONFIG\nset $THIS_ROOT/NETMASK $NETMASK"
+                        break
+                        ;;
+                esac
+                ;;
+        esac
+    done
+
+    if [ "$bridge" == "N" ]; then
+        printf "Is $NIC bridged? (Y/N) "
+        read
+        case $REPLY in
+            Y|y)
+                printf "What is the bridge name? "
+                read
+                CONFIG="$CONFIG\n set $THIS_ROOT/BRIDGE $REPLY"
+                ;;
+        esac
+    fi
+
+    CONFIG="$CONFIG\nset $THIS_ROOT/ONBOOT yes"
+    printf "$CONFIG\n" > $FILENAME
+
+    echo
+}
+
+# TODO the menu doesn't redisplay unless you hit enter -- needs fixing
+# get the list of network cards on this machine
+NICS=$(hal-device | awk '/net.interface/ {
+    match($0, "= '"'"'(.*)'"'"' ", nic); printf("%s ", nic[1]); }')
+
+# Append a quit option
+NICS="$NICS Quit"
+
+PS3="Please select a network interface to configure:"
+select NIC in $NICS
+do
+    case "$NIC" in
+        "Quit")
+            break
+            ;;
+
+        *)
+            configure_interface $NIC
+            ;;
+    esac
+done
+
+# Merge together all generated files and run augtool
+
+cat /var/tmp/augtool-* > /var/tmp/config-augtool
+augtool < /var/tmp/config-augtool
-- 
1.5.6.5




More information about the ovirt-devel mailing list