Explorar o código

AMBARI-2577. core-site proxyuser properties doesn't persist user values while dynamically creating keys on re-running installer wizard. (Andrii Tkach via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1500103 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako %!s(int64=12) %!d(string=hai) anos
pai
achega
1e8cc190a0

+ 2 - 59
ambari-web/app/controllers/wizard/step14_controller.js

@@ -390,10 +390,10 @@ App.WizardStep14Controller = Em.Controller.extend({
     }, this);
     var dependentConfig = this.get('configMapping').filterProperty('foreignKey');
     dependentConfig.forEach(function (_config) {
-      this.setConfigValue(uiConfig, _config);
+      App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
       uiConfig.pushObject({
         "id": "site property",
-        "name": _config.name,
+        "name": _config._name || _config.name,
         "value": _config.value,
         "filename": _config.filename
       });
@@ -434,63 +434,6 @@ App.WizardStep14Controller = Em.Controller.extend({
     }, this);
     return value;
   },
-  /**
-   * Set all site property that are derived from other site-properties
-   */
-  setConfigValue: function (uiConfig, config) {
-    if (config.value == null) {
-      return;
-    }
-    var fkValue = config.value.match(/<(foreignKey.*?)>/g);
-    if (fkValue) {
-      fkValue.forEach(function (_fkValue) {
-        var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
-        if (uiConfig.someProperty('name', config.foreignKey[index])) {
-          var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
-          config.value = config.value.replace(_fkValue, globalValue);
-        } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
-          var globalValue;
-          if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
-          } else {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
-          }
-          config.value = config.value.replace(_fkValue, globalValue);
-        }
-      }, this);
-    }
-    if (fkValue = config.name.match(/<(foreignKey.*?)>/g)) {
-      fkValue.forEach(function (_fkValue) {
-        var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
-        if (uiConfig.someProperty('name', config.foreignKey[index])) {
-          var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
-          config.name = config.name.replace(_fkValue, globalValue);
-        } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
-          var globalValue;
-          if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
-          } else {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
-          }
-          config.name = config.name.replace(_fkValue, globalValue);
-        }
-      }, this);
-    }
-    //For properties in the configMapping file having foreignKey and templateName properties.
-
-    var templateValue = config.value.match(/<(templateName.*?)>/g);
-    if (templateValue) {
-      templateValue.forEach(function (_value) {
-        var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
-        if (this.get('globals').someProperty('name', config.templateName[index])) {
-          var globalValue = this.get('globals').findProperty('name', config.templateName[index]).value;
-          config.value = config.value.replace(_value, globalValue);
-        } else {
-          config.value = null;
-        }
-      }, this);
-    }
-  },
 
   /**
    * Set property of the site variable

+ 2 - 60
ambari-web/app/controllers/wizard/step8_controller.js

@@ -190,10 +190,10 @@ App.WizardStep8Controller = Em.Controller.extend({
     }, this);
     var dependentConfig = this.get('configMapping').filterProperty('foreignKey');
     dependentConfig.forEach(function (_config) {
-      this.setConfigValue(uiConfig, _config);
+      App.config.setConfigValue(uiConfig, this.get('content.serviceConfigProperties'), _config, this.get('globals'));
       uiConfig.pushObject({
         "id": "site property",
-        "name": _config.name,
+        "name": _config._name || _config.name,
         "value": _config.value,
         "filename": _config.filename
       });
@@ -322,64 +322,6 @@ App.WizardStep8Controller = Em.Controller.extend({
     return value;
   },
 
-  /**
-   * Set all site property that are derived from other site-properties
-   */
-  setConfigValue: function (uiConfig, config) {
-    if (config.value == null) {
-      return;
-    }
-    var fkValue = config.value.match(/<(foreignKey.*?)>/g);
-    if (fkValue) {
-      fkValue.forEach(function (_fkValue) {
-        var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
-        if (uiConfig.someProperty('name', config.foreignKey[index])) {
-          var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
-          config.value = config.value.replace(_fkValue, globalValue);
-        } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
-          var globalValue;
-          if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
-          } else {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
-          }
-          config.value = config.value.replace(_fkValue, globalValue);
-        }
-      }, this);
-    }
-    if (fkValue = config.name.match(/<(foreignKey.*?)>/g)) {
-      fkValue.forEach(function (_fkValue) {
-        var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
-        if (uiConfig.someProperty('name', config.foreignKey[index])) {
-          var globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
-          config.name = config.name.replace(_fkValue, globalValue);
-        } else if (this.get('content.serviceConfigProperties').someProperty('name', config.foreignKey[index])) {
-          var globalValue;
-          if (this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value === '') {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).defaultValue;
-          } else {
-            globalValue = this.get('content.serviceConfigProperties').findProperty('name', config.foreignKey[index]).value;
-          }
-          config.name = config.name.replace(_fkValue, globalValue);
-        }
-      }, this);
-    }
-    //For properties in the configMapping file having foreignKey and templateName properties.
-
-    var templateValue = config.value.match(/<(templateName.*?)>/g);
-    if (templateValue) {
-      templateValue.forEach(function (_value) {
-        var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
-        if (this.get('globals').someProperty('name', config.templateName[index])) {
-          var globalValue = this.get('globals').findProperty('name', config.templateName[index]).value;
-          config.value = config.value.replace(_value, globalValue);
-        } else {
-          config.value = null;
-        }
-      }, this);
-    }
-  },
-
   /**
    * Load all info about cluster to <code>clusterInfo</code> variable
    */

+ 60 - 0
ambari-web/app/utils/config.js

@@ -735,6 +735,66 @@ App.config = Em.Object.create({
       }
     });
     console.log("loadServiceConfigHostsOverrides(): Finished loading.");
+  },
+
+  /**
+   * Set all site property that are derived from other site-properties
+   */
+  setConfigValue: function (mappedConfigs, allConfigs, config, globalConfigs) {
+    var globalValue;
+    if (config.value == null) {
+      return;
+    }
+    var fkValue = config.value.match(/<(foreignKey.*?)>/g);
+    var fkName = config.name.match(/<(foreignKey.*?)>/g);
+    var templateValue = config.value.match(/<(templateName.*?)>/g);
+    if (fkValue) {
+      fkValue.forEach(function (_fkValue) {
+        var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
+        if (mappedConfigs.someProperty('name', config.foreignKey[index])) {
+          globalValue = mappedConfigs.findProperty('name', config.foreignKey[index]).value;
+          config.value = config.value.replace(_fkValue, globalValue);
+        } else if (allConfigs.someProperty('name', config.foreignKey[index])) {
+          if (allConfigs.findProperty('name', config.foreignKey[index]).value === '') {
+            globalValue = allConfigs.findProperty('name', config.foreignKey[index]).defaultValue;
+          } else {
+            globalValue = allConfigs.findProperty('name', config.foreignKey[index]).value;
+          }
+          config.value = config.value.replace(_fkValue, globalValue);
+        }
+      }, this);
+    }
+
+    // config._name - formatted name from original config name
+    if (fkName) {
+      fkName.forEach(function (_fkName) {
+        var index = parseInt(_fkName.match(/\[([\d]*)(?=\])/)[1]);
+        if (mappedConfigs.someProperty('name', config.foreignKey[index])) {
+          globalValue = mappedConfigs.findProperty('name', config.foreignKey[index]).value;
+          config._name = config.name.replace(_fkName, globalValue);
+        } else if (allConfigs.someProperty('name', config.foreignKey[index])) {
+          if (allConfigs.findProperty('name', config.foreignKey[index]).value === '') {
+            globalValue = allConfigs.findProperty('name', config.foreignKey[index]).defaultValue;
+          } else {
+            globalValue = allConfigs.findProperty('name', config.foreignKey[index]).value;
+          }
+          config._name = config.name.replace(_fkName, globalValue);
+        }
+      }, this);
+    }
+
+    //For properties in the configMapping file having foreignKey and templateName properties.
+    if (templateValue) {
+      templateValue.forEach(function (_value) {
+        var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
+        if (globalConfigs.someProperty('name', config.templateName[index])) {
+          var globalValue = globalConfigs.findProperty('name', config.templateName[index]).value;
+          config.value = config.value.replace(_value, globalValue);
+        } else {
+          config.value = null;
+        }
+      }, this);
+    }
   }
 
 });