Index: /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c
===================================================================
--- /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c	(revision 40277)
+++ /branches/rel_apv_10_7/usr/click/bin/backend/ntp.c	(working copy)
@@ -223,7 +223,7 @@
     return access(CHRONYD_PID_FILE, F_OK) == 0;
 }
 
-static void add_ntpsrv_conf(char *host, char *cfg) 
+static int add_ntpsrv_conf(char *host, char *cfg) 
 {
     FILE *fp, *fp_tmp;
     char linebuf[2048] = {0}, prefix[1024] = {0};
@@ -254,6 +254,7 @@
             (linebuf[strlen(prefix)] == '\0' || 
              linebuf[strlen(prefix)] == ' ' || 
              linebuf[strlen(prefix)] == '\n')) {
+            found = 1;
             continue;
         } else {
             fputs(linebuf, fp_tmp);
@@ -268,6 +269,8 @@
 
     unlink(CHRONY_CONF_FILE);
     rename(CHRONY_CONF_TMP, CHRONY_CONF_FILE);
+
+    return found;
 }
 
 int ui_ntpoff()
@@ -355,11 +358,10 @@
 
 int ui_ntpserver(char *host, char *option, int key_id) 
 {
-    char srv_config[1024] = {0}, cmd[1024], copy[256] = {0};
+    char srv_config[1024] = {0}, cmd[1024], delete_cmd[1024], copy[256] = {0};
     char *token, *support_options[] = {"nts", "iburst"};
     int cases = sizeof(support_options) / sizeof(support_options[0]);
     int i, support = 0;
-    FILE *fp = NULL;
 
     /* Check input hostname */
     if (host == NULL || *host == '\0') {
@@ -406,11 +408,16 @@
     }
 
     /* Add server config into chrony.conf */
-    add_ntpsrv_conf(host, srv_config);
+    int is_exist = add_ntpsrv_conf(host, srv_config);
 
     /* Dynamically add to chrony if daemon is running */
     if(isntpon()) {
         sprintf(cmd, "%s %s", CHRONYC_ADD_SRV_CMD, srv_config);
+        if (is_exist) {
+            snprintf(delete_cmd, sizeof(delete_cmd), "%s %s", CHRONYC_DEL_SRV_CMD, host);
+            system(delete_cmd);
+            system(CHRONYC_RESET_CMD);
+        }
         system(cmd);
     }
 
Index: /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/apv/models/system/ntp.py
===================================================================
--- /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/apv/models/system/ntp.py	(revision 40277)
+++ /branches/rel_apv_10_7/usr/click/webui/htdocs/new/src/apv/models/system/ntp.py	(working copy)
@@ -86,8 +86,8 @@
     options = MultiEnumField(verbose_name=_('NTP Server Options'), default=[], optional=True, values=(
         ('nts', 'NTS'),
         ('iburst', 'iBurst'),
-    ))
-    key_id = AssoField2(verbose_name=_('Authentication Key'), tgt='system.NTPKey.ntpserver_key', mul='*', pos='right', optional=True)
+    ), editable=True)
+    key_id = AssoField2(verbose_name=_('Authentication Key'), tgt='system.NTPKey.ntpserver_key', mul='*', pos='right', editable=True)
     asso = AssoField2(tgt='system.NTPSettings.ntp_server', mul='*', pos='right', hidden=True, default=[{}])
 
     class Meta:
@@ -143,8 +143,11 @@
                                       BlankParser(nonblank_exception=CLICmdError, supplement=True))
             return
 
+        def _update(self, instance):
+            return self._insert(instance)
+
 class NTPKey(ANModel):
-    key_id = Uint32Field(verbose_name=_('Key ID'), primary_key=True)
+    key_id = Uint32Field(verbose_name=_('Key ID'), primary_key=True, scope='1..65535')
     auth_key = PasswordField(verbose_name=_('Authentication Key'), length='1..32', confirm=False)
     tgt_fields = FieldGroup(level=ADVANCED, editable=False, fields={
         'setting_key': AssoField2(verbose_name=_(''), tgt='system.NTPSettings.ntp_key', mul='*', pos='right', optional=True, hidden=True),
