[Ovirt-devel] [PATCH node] Adds automatic non-interactive configuration for the standalone node.
Darryl L. Pierce
dpierce at redhat.com
Fri Nov 14 16:20:19 UTC 2008
If ovirt-config-network is called as follows:
ovirt-config-network AUTO [NIC] [IP NETMASK GATEWAY BROADCAST]
where NIC is the management interface to be configured.
If the IP details are provided then they are used to configure the device.
Otherwise DHCP will be used.
Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
scripts/ovirt-config-networking | 82 +++++++++++++++++++++++++++------------
scripts/ovirt-firstboot | 6 ++-
2 files changed, 62 insertions(+), 26 deletions(-)
diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index 2f8363c..583ee5e 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -4,11 +4,17 @@
# to configure each.
CONFIG_FILE_ROOT="/file/etc/sysconfig/network-scripts/ifcfg"
-CONFIG_LOG_FILE="/var/log/ovirt-network-setup.log"
+# CONFIG_LOG_FILE="/var/log/ovirt-network-setup.log"
+CONFIG_LOG_FILE="ovirt-network-setup.log"
function configure_interface
{
NIC=$1
+ AUTO=$2
+ IPADDR=$3
+ NETMASK=$4
+ GATEWAY=$5
+ BROADCAST=$6
BRIDGE=ovirtbr`echo $NIC | cut -b4-`
IF_FILENAME="/var/tmp/augtool-$NIC"
BR_FILENAME="/var/tmp/augtool-$BRIDGE"
@@ -27,21 +33,33 @@ function configure_interface
# how do you want to configure this device? (dhcp, static IP)
while true; do
- printf "Will $BRIDGE use dynamic addressing? (Y/N) "
- read
+ if [ -z "$AUTO" ]; then
+ read -p "Will $BRIDGE use dynamic addressing? (Y/N) "
+ else
+ if [ -z "$IPADDR" ]; then
+ REPLY="Y"
+ else
+ REPLY="N"
+ fi
+ fi
+
case $REPLY in
Y|y) BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO dhcp"; break ;;
N|n)
- printf "\nPlease enter the network details for $BRIDGE:\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 "\nPlease review the details for $BRIDGE:\n"
- printf "\tIP Address: $IPADDR\n \t Netmask: $NETMASK\n\t Broadcast: $BROADCAST\n\t Gateway: $GATEWAY\n"
- printf "Is this correct? (Y/N) "
- read
+ if [ -z "$IPADDR" ]; then
+ printf "\nPlease enter the network details for $BRIDGE:\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 "\nPlease review the details for $BRIDGE:\n"
+ printf "\tIP Address: $IPADDR\n \t Netmask: $NETMASK\n\t Broadcast: $BROADCAST\n\t Gateway: $GATEWAY\n"
+ read -p "Is this correct? (Y/N) "
+ else
+ REPLY="Y"
+ fi
+
case $REPLY in
Y|y)
BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR"
@@ -70,21 +88,35 @@ function setup_menu
PS3="Please select a network interface to configure:"
}
-# clean up any left over configurations
-rm -f /var/tmp/config-augtool
-rm -f /var/tmp/augtool-*
+# if we're in autoconfig mode, then iterate over all network interfaces and
+# set them use DHCP
-setup_menu
+if [ "$1" == "AUTO" ]; then
+ if [ -n "$2" ]; then
+ configure_interface $2 AUTO $3 $4 $5 $6
+ else
+ printf "No network interface specified to auto-configure. Exiting...\n"
+ exit 1
+ fi
+else
+
+ # clean up any left over configurations
+ rm -f /var/tmp/config-augtool
+ rm -f /var/tmp/augtool-*
-select NIC in $NICS
-do
- printf "\n"
- case "$NIC" in
- "Quit") break ;;
- *) configure_interface $NIC $IFACE_NUMBER ;;
- esac
setup_menu
-done
+
+ select NIC in $NICS
+ do
+ printf "\n"
+ case "$NIC" in
+ "Quit") break ;;
+ *) configure_interface $NIC $IFACE_NUMBER ;;
+ esac
+ setup_menu
+ done
+
+fi
# Merge together all generated files and run augtool
diff --git a/scripts/ovirt-firstboot b/scripts/ovirt-firstboot
index 82d9e48..f93ba1b 100755
--- a/scripts/ovirt-firstboot
+++ b/scripts/ovirt-firstboot
@@ -29,7 +29,11 @@
start ()
{
- ovirt-config-setup
+ if is_interactive_firstboot; then
+ ovirt-config-setup
+ else
+ ovirt-config-network AUTO
+ fi
}
case "$1" in
--
1.5.6.5
More information about the ovirt-devel
mailing list