[Ovirt-devel] [PATCH node] Restricts network configuration to a single NIC.
Alan Pevec
apevec at redhat.com
Wed May 27 14:39:50 UTC 2009
From: Darryl L. Pierce <dpierce at redhat.com>
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 | 45 ++++++++++++++++++++++++++++++++-------
1 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index e8a8624..d964ee8 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"
@@ -85,7 +97,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"
@@ -107,7 +119,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"
@@ -122,7 +134,7 @@ function configure_interface
break
;;
N|n) BR_CONFIG=$BR_CONFIG_BASE ;;
- A|a) return ;;
+ A|a) CONFIGURED_NIC=""; return;;
esac
done
else
@@ -278,14 +290,23 @@ else
while true; do
printf "\n\n Networking Configuration\n\n" >&2
-
- select NIC in $NICS "DNS" "NTP" "Save And Return To Menu"
+ printf "***** WARNING *****\n"
+ printf "Configuring the network will destroy any existing networking\n"
+ printf "configuration on this system.\n"
+ printf "***** WARNING *****\n"
+
+ DNS="DNS"
+ NTP="NTP"
+ Abort="Abort"
+ Save="Save And Return To Menu"
+ select NIC in $NICS "$DNS" "$NTP" "$Abort" "$Save"
do
printf "\n"
case "$NIC" in
- "DNS") configure_dns "$OVIRT_DNS"; break ;;
- "NTP") configure_ntp "$OVIRT_NTP"; break ;;
- "Save And Return To Menu") break 2;;
+ "$DNS") configure_dns "$OVIRT_DNS"; break ;;
+ "$NTP") configure_ntp "$OVIRT_NTP"; break ;;
+ "$Abort") rm -f "${WORKDIR}"/augtool-*; exit 99;;
+ "$Save") break 2;;
*)
if [[ -n "${NIC}" ]] && [[ "${NICS}" =~ "${NIC}" ]]; then
configure_interface $NIC $IFACE_NUMBER
@@ -303,6 +324,14 @@ 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
+ ovirt_safe_delete_config $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