Darryl L. Pierce
2009-Nov-11 20:02 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 7d4e363..781553c 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 { @@ -167,9 +189,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.2.5
Darryl L. Pierce
2009-Dec-03 21:32 UTC
[Ovirt-devel] Re: [PATCH] Static IPv4 addresses entered are validated when they're entered.
On Wed, Nov 11, 2009 at 03:02:27PM -0500, Darryl L. Pierce wrote:> 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> > ---Can I get an ACK or feedback on this patch, please? -- Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. Delivering value year after year. Red Hat ranks #1 in value among software vendors. http://www.redhat.com/promo/vendor/ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: not available URL: <http://listman.redhat.com/archives/ovirt-devel/attachments/20091203/4045a89a/attachment.sig>
Reasonably Related Threads
- [PATCH node] validify ipv4/ipv6 static/dhcp choice else loop
- [PATCH node] Adds vlan support to auto-installations for the node. bz#511056
- [PATCH node] add network.py script
- [PATCH node] Restricts network configuration to a single NIC.
- [PATCH node] Rerunning network config resets all network config. bz#507393