[Ovirt-devel] [PATCH node] Restricts network configuration to a single NIC.

Darryl L. Pierce dpierce at redhat.com
Fri May 22 19:12:57 UTC 2009


If an existing set of configuration files exist they are deleted. While
in the configuration menu, only one NIC is configured. If the user
selects a second network card to configure then the previous
configuration is discarded and only the new one saved.

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

diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 46f74da..8a73e7c 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -18,6 +18,7 @@ trap 'exit $?' 1 2 13 15
 
 CONFIG_FILE_ROOT="/files/etc/sysconfig/network-scripts/ifcfg"
 NTP_CONFIG_FILE="/etc/ntp.conf"
+CONFIGURED_NIC=""
 
 function configure_interface
 {
@@ -31,6 +32,17 @@ function configure_interface
         PREFIX=$OVIRT_IP_PREFIX
     fi
 
+    if [[ -n "${CONFIGURED_NIC}" ]]; then
+        printf "This will delete the current configuration for ${CONFIGURED_NIC}.\n"
+        read -ep "Continue? (y/N) "
+        case $REPLY in
+            N|n) printf "\nAborting...\n"; return;;
+        esac
+    fi
+
+    rm -rf $WORKDIR/*
+    CONFIGURED_NIC=$NIC
+
     local BRIDGE=br$NIC
     local IF_FILENAME="$WORKDIR/augtool-$NIC"
     local BR_FILENAME="$WORKDIR/augtool-$BRIDGE"
@@ -69,7 +81,7 @@ function configure_interface
                         BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/GATEWAY $GATEWAY"
                     fi
                     ;;
-                A|a) return ;;
+                A|a) CONFIGURED_NIC=""; return ;;
             esac
 
             printf "\n"
@@ -91,7 +103,7 @@ function configure_interface
                     BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6FORWARDING no"
                     BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPV6AUTOCONF yes"
                     ;;
-                A|a) return ;;
+                A|a) CONFIGURED_NIC=""; return;;
             esac
 
             printf "\n"
@@ -106,7 +118,7 @@ function configure_interface
                         break
                     ;;
                 N|n) BR_CONFIG=$BR_CONFIG_BASE ;;
-                A|a) return ;;
+                A|a) CONFIGURED_NIC=""; return;;
             esac
         done
     else
@@ -262,6 +274,10 @@ else
 
     while true; do
         printf "\n\n Networking Configuration\n\n" >&2
+        printf "***** WARNING *****\n"
+        printf "Configuring the network will destroy any existing networking\n"
+        printf "configuration on this system.\n"
+        printf "***** WARNING *****\n"
 
         select NIC in $NICS "DNS" "NTP" "Save & Exit"
         do
@@ -269,6 +285,7 @@ else
             case "$NIC" in
                 "DNS") configure_dns "$OVIRT_DNS"; break ;;
 		"NTP") configure_ntp "$OVIRT_NTP"; break ;;
+                "Abort") rm -f "${WORKDIR}"/augtool-*; exit 99;;
                 "Save & Exit") break 2;;
                 *)
                     if [[ -n "${NIC}" ]] && [[ "${NICS}" =~ "${NIC}" ]]; then
@@ -287,6 +304,12 @@ start_log
 net_configured=0
 if ls "$WORKDIR"/augtool-* > /dev/null 2>&1 ; then
     log "Configuring network"
+
+    # delete existing scripts
+    for script in /etc/sysconfig/network-scripts/ifcfg-*; do
+        if [[ ! "${script}" =~ ifcfg-lo ]]; then rm -f $script; fi
+    done
+
     config="$WORKDIR"/config-augtool
     cat "$WORKDIR"/augtool-* > $config \
         && augtool $config
-- 
1.6.0.6




More information about the ovirt-devel mailing list