This version of the patch was rebased to go on top of recent changes committed to ovirt-config-networking on next.
Darryl L. Pierce
2009-Dec-07 22:12 UTC
[Ovirt-devel] [PATCH] Static IPv4 addresses entered are validated when they're entered.
If the address is not blank then it is validated. Only those that are properly formed are accepted. Otherwise an error message is displayed and the user is prompted again. Resolves: rhbz#536912 - validation for static IP should be optimized Signed-off-by: Darryl L. Pierce <dpierce at redhat.com> --- scripts/ovirt-config-networking | 28 +++++++++++++++++++++++++--- 1 files changed, 25 insertions(+), 3 deletions(-) diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking index f9c6a4c..ec154c2 100755 --- a/scripts/ovirt-config-networking +++ b/scripts/ovirt-config-networking @@ -30,6 +30,28 @@ if ! is_local_storage_configured; then exit 99 fi +# $1 - the variable name to set +# $2 - the input prompt +function input_ipv4_address { + local varname=$1 + local prompt=$2 + + eval $varname=\"\" + + while true; do + read -ep "${prompt}: " + + if [ -z "$REPLY" ]; then return; fi + + if is_valid_ipv4 $REPLY; then + eval $varname=\"$REPLY\" + return + else + printf "\nThe address $REPLY is not a valid IPv4 address.\n" + fi + done +} + # Checks that a network interface was already configured. function has_configured_interface { @@ -169,9 +191,9 @@ function configure_interface ;; S|s) printf "\n" - read -ep "IP Address: "; IPADDR=$REPLY - read -ep " Netmask: "; NETMASK=$REPLY - read -ep " Gateway: "; GATEWAY=$REPLY + input_ipv4_address IPADDR "IP Address" + input_ipv4_address NETMASK " Netmask" + input_ipv4_address GATEWAY " Gateway" BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/BOOTPROTO none" BR_CONFIG="$BR_CONFIG\nset $BR_ROOT/IPADDR $IPADDR" -- 1.6.5.2
Possibly Parallel Threads
- [PATCH node] Adds vlan support to auto-installations for the node. bz#511056
- [PATCH node] validify ipv4/ipv6 static/dhcp choice else loop
- Obsoletes previous patch
- [PATCH node] Rerunning network config resets all network config. bz#507393
- [PATCH node] REPOST Joey's and Darryl's ovirt-config-* patches