[Ovirt-devel] [PATCH node] remove ipv4 validation for ntp and rely on actual ntp verification

Joey Boggs jboggs at redhat.com
Thu Feb 11 16:19:27 UTC 2010


---
 scripts/ovirt-config-networking |   13 ++++++-------
 scripts/ovirt-functions         |   16 ++++++++++++++++
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/scripts/ovirt-config-networking b/scripts/ovirt-config-networking
index ec154c2..40a2d2c 100755
--- a/scripts/ovirt-config-networking
+++ b/scripts/ovirt-config-networking
@@ -414,12 +414,7 @@ function configure_ntp
 	        read -ep "Enter an NTP server (hit return when finished): "
 
 	        if [ -z "$REPLY" ]; then break; fi
-
-                if is_valid_ipv4 $REPLY; then
-                    NTPSERVERS="${NTPSERVERS}:${REPLY}"
-                else
-                    printf "${REPLY} is an invalid address.\n"
-                fi
+                NTPSERVERS="${NTPSERVERS}:${REPLY}"
 	    done
         fi
     fi
@@ -560,5 +555,9 @@ if [ "$net_configured" = 1 ]; then
       ifconfig $i down
       brctl delbr $i
     done
-    service network start
+    service network start 2> /dev/null
+    if [ $NTPSERVERS ]; then
+        log "Testing NTP Configuration"
+        test_ntp_configuration
+    fi
 fi
diff --git a/scripts/ovirt-functions b/scripts/ovirt-functions
index 6435387..48d0e39 100644
--- a/scripts/ovirt-functions
+++ b/scripts/ovirt-functions
@@ -729,6 +729,22 @@ is_valid_ipv4 () {
     return $result
 }
 
+test_ntp_configuration () {
+    # stop ntpd service for testing
+    service ntpd stop > /dev/null 2>&1
+    SERVERS=$(echo $NTPSERVERS | awk 'BEGIN{FS=":"}{for (i=1; i<=NF; i++) print $i}')
+        for server in $SERVERS; do
+            ntpdate $server > /dev/null 2>&1
+            result=$?
+            if [ $result -ne 0 ]; then
+                printf "\n Unable to verify NTP server: $server \n"
+            else
+                printf "\n Verified NTP server: $server \n"
+            fi
+        done
+
+}
+
 # execute a function if called as a script, e.g.
 #   ovirt-functions ovirt_store_config /etc/hosts
 
-- 
1.6.6




More information about the ovirt-devel mailing list