Index: /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/avx/models/system/ntp.py
===================================================================
--- /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/avx/models/system/ntp.py	(revision 9074)
+++ /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/avx/models/system/ntp.py	(working copy)
@@ -4,6 +4,7 @@
 from ast import literal_eval
 from hive.model.legacycli import cli_parse
 import re
+from hive.utils import is_ip_or_hostname
 
 class NTPSettings(ANModel):
     enable_ntp = BooleanField(verbose_name=_('Enable NTP'))
@@ -117,25 +118,19 @@
 
         def _insert(self, instance):
             available_options = ['', 'nts', 'iburst']
-            data = instance.get_field_dict()
-            ip_str = ""
-            ip_dict = literal_eval(data["ip"])
-            if "hostname" in ip_dict:
-                ip_str = ip_dict["hostname"]
-            elif "ipv4" in ip_dict:
-                ip_str = ip_dict["ipv4"]
-            elif "ipv6" in ip_dict:
-                ip_str = ip_dict["ipv6"]
+            if not hasattr(instance, 'ip') or not is_ip_or_hostname(instance.ip):
+                return cli_parse("Please check fields", BlankParser(nonblank_exception=CLICmdError, nonblank_msg="Please check fields"))
+            ip_str = instance.ip
             options_str = '""'
-            if "options" in data and data["options"]:
-                if data["options"] not in available_options:
+            if hasattr(instance, 'options') and instance.options:
+                if instance.options not in available_options:
                     return cli_parse("Invalid options", BlankParser(nonblank_exception=CLICmdError, nonblank_msg="Invalid options"))
-                options_str = '"' + str(data["options"]) + '"'
+                options_str = '"' + str(instance.options) + '"'
             if not ip_str:
                 return cli_parse("Please check fields", BlankParser(nonblank_exception=CLICmdError, nonblank_msg="Please check fields"))
             key_str = ""
-            if "key_id" in data and data["key_id"]:
-                key_str = data["key_id"]
+            if hasattr(instance, 'key_id') and instance.key_id:
+                key_str = instance.key_id
             self.cli.set_config()
             result = self.cli.cmd('ntp server "%s" %s %s' % (ip_str, options_str, key_str),
                                   BlankParser(nonblank_exception=CLICmdError, supplement=True))
Index: /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/client/app/modules/system/submenu/general/ntp/ntp.controller.js
===================================================================
--- /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/client/app/modules/system/submenu/general/ntp/ntp.controller.js	(revision 9074)
+++ /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/client/app/modules/system/submenu/general/ntp/ntp.controller.js	(working copy)
@@ -207,11 +207,11 @@
                 showProgressBar();
                 var post_data={"options":data["options"], "key_id":parseInt(data["key_id"])};
                 if (modalViewModel.chooseIpv4) {
-                    post_data['ip'] = {'ipv4':data['ipv4']};
+                    post_data['ip'] = data['ipv4'];
                 } else if (modalViewModel.chooseIpv6) {
-                    post_data['ip'] = {'ipv6':data['ipv6']};
+                    post_data['ip'] = data['ipv6'];
                 } else {
-                    post_data['ip'] = {'hostname':data['hostname']};
+                    post_data['ip'] = data['hostname'];
                 }
                 sysResourceService
                     .add_ntp_server(post_data)
Index: /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/hive/utils.py
===================================================================
--- /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/hive/utils.py	(revision 9074)
+++ /branches/rel_avx_2_7_4/src/webui/webui/htdocs/new/src/hive/utils.py	(working copy)
@@ -15,6 +15,7 @@
 from djproject.an_settings import LOGICVIEW_DATA
 from django.views.decorators.csrf import csrf_exempt
 import cgi
+import re
 
 import Queue
     
@@ -567,7 +568,19 @@
         except:
             return False
     return True
-    
+def is_ip_or_hostname(value):
+    ipv4_pattern = r'^(\d{1,3}\.){3}\d{1,3}$'
+    ipv6_pattern = r'^([0-9a-fA-F]{0,4}:){2,7}[0-9a-fA-F]{0,4}$'
+    hostname_pattern = r'^(?=.{1,253}$)(?![0-9.]+$)([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$'
+    if re.match(ipv4_pattern, value):
+        return 'ipv4'
+    elif re.match(ipv6_pattern, value):
+        return 'ipv6'
+    elif re.match(hostname_pattern, value):
+        return 'hostname'
+    else:
+        return ''
+
 def get_sysctl_int(name):
     libc = ctypes.CDLL("/lib/libc.so.7")
     size = ctypes.c_uint(0)
