You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2015/09/23 10:45:48 UTC

ambari git commit: AMBARI-13199 addHostNamesToConfigs shouldn't be run on Kerberos. (ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 78578ae88 -> d2062484f


AMBARI-13199 addHostNamesToConfigs shouldn't be run on Kerberos. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/d2062484
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d2062484
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d2062484

Branch: refs/heads/branch-2.1
Commit: d2062484f42e53e57b8ce78ee9f592e08143b947
Parents: 78578ae
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Wed Sep 23 11:42:58 2015 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Wed Sep 23 11:45:46 2015 +0300

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 99 +++++++++++++++++++-
 ambari-web/app/utils/config.js                  | 93 ------------------
 .../test/controllers/wizard/step7_test.js       | 14 +--
 3 files changed, 104 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d2062484/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 0f62b3a..1b25156 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -17,6 +17,7 @@
  */
 
 var App = require('app');
+var configPropertyHelper = require('utils/configs/config_property_helper');
 /**
  * By Step 7, we have the following information stored in App.db and set on this
  * controller by the router.
@@ -743,7 +744,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
       masterComponentHosts: this.get('wizardController.content.masterComponentHosts'),
       slaveComponentHosts: this.get('wizardController.content.slaveComponentHosts')
     };
-    var serviceConfigs = App.config.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
+    var serviceConfigs = this.renderConfigs(configs, storedConfigs, this.get('allSelectedServiceNames'), this.get('installedServiceNames'), localDB);
     if (this.get('wizardController.name') === 'addServiceController') {
       serviceConfigs.setEach('showConfig', true);
       serviceConfigs.setEach('selected', false);
@@ -783,6 +784,100 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
   },
 
   /**
+   * render configs, distribute them by service
+   * and wrap each in ServiceConfigProperty object
+   * @param configs
+   * @param storedConfigs
+   * @param allSelectedServiceNames
+   * @param installedServiceNames
+   * @param localDB
+   * @return {App.ServiceConfig[]}
+   */
+  renderConfigs: function (configs, storedConfigs, allSelectedServiceNames, installedServiceNames, localDB) {
+    var renderedServiceConfigs = [];
+    var services = [];
+
+    App.config.get('preDefinedServiceConfigs').forEach(function (serviceConfig) {
+      var serviceName = serviceConfig.get('serviceName');
+      if (allSelectedServiceNames.contains(serviceName) || serviceName === 'MISC') {
+        if (!installedServiceNames.contains(serviceName) || serviceName === 'MISC') {
+          serviceConfig.set('showConfig', true);
+        }
+        services.push(serviceConfig);
+      }
+    });
+    services.forEach(function (service) {
+      var configsByService = [];
+      var serviceConfigs = configs.filterProperty('serviceName', service.get('serviceName'));
+      serviceConfigs.forEach(function (_config) {
+        var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
+        this.updateHostOverrides(serviceConfigProperty, _config);
+        if (!storedConfigs && !serviceConfigProperty.get('hasInitialValue')) {
+          configPropertyHelper.initialValue(serviceConfigProperty, localDB, configs);
+        }
+        serviceConfigProperty.validate();
+        configsByService.pushObject(serviceConfigProperty);
+      }, this);
+      var serviceConfig = App.config.createServiceConfig(service.get('serviceName'));
+      serviceConfig.set('showConfig', service.get('showConfig'));
+      serviceConfig.set('configs', configsByService);
+      if (['addServiceController', 'installerController'].contains(this.get('wizardController.name'))) {
+        this.addHostNamesToConfigs(serviceConfig, localDB.masterComponentHosts, localDB.slaveComponentHosts);
+      }
+      renderedServiceConfigs.push(serviceConfig);
+    }, this);
+    return renderedServiceConfigs;
+  },
+
+  /**
+   * Add host name properties to appropriate categories (for installer only)
+   * @param serviceConfig
+   * @param masterComponents
+   * @param slaveComponents
+   */
+  addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) {
+    serviceConfig.get('configCategories').forEach(function(c) {
+      if (c.showHost) {
+        var value = [];
+        var componentName = c.name;
+        var masters = masterComponents.filterProperty('component', componentName);
+        if (masters.length) {
+          value = masters.mapProperty('hostName');
+        } else {
+          var slaves = slaveComponents.findProperty('componentName', componentName);
+          if (slaves) {
+            value = slaves.hosts.mapProperty('hostName');
+          }
+        }
+        var stackComponent = App.StackServiceComponent.find(componentName);
+        var hProperty = App.config.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
+        serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
+      }
+    }, this);
+  },
+
+  /**
+   * create new child configs from overrides, attach them to parent config
+   * override - value of config, related to particular host(s)
+   * @param configProperty
+   * @param storedConfigProperty
+   */
+  updateHostOverrides: function (configProperty, storedConfigProperty) {
+    if (storedConfigProperty.overrides != null && storedConfigProperty.overrides.length > 0) {
+      var overrides = [];
+      storedConfigProperty.overrides.forEach(function (overrideEntry) {
+        // create new override with new value
+        var newSCP = App.ServiceConfigProperty.create(configProperty);
+        newSCP.set('value', overrideEntry.value);
+        newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
+        newSCP.set('parentSCP', configProperty);
+        overrides.pushObject(newSCP);
+      });
+      configProperty.set('overrides', overrides);
+    }
+  },
+
+  /**
    * When NameNode HA is enabled some configs based on <code>dfs.nameservices</code> should be changed
    * This happens only if service is added AFTER NN HA is enabled
    *
@@ -907,7 +1002,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E
     Em.keys(configsMap).forEach(function (filename) {
       Em.keys(configsMap[filename]).forEach(function (propertyName) {
         configs.push(configMixin.createDefaultConfig(propertyName,
-          configMixin.getServiceByConfigType(filename).get('serviceName'),
+          configMixin.getServiceByConfigType(filename) ? configMixin.getServiceByConfigType(filename).get('serviceName') : 'MISC',
           configMixin.getOriginalFileName(filename),
           false, {
             value: configsMap[filename][propertyName],

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2062484/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index b582a40..1e9b262 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -18,7 +18,6 @@
 
 var App = require('app');
 var stringUtils = require('utils/string_utils');
-var configPropertyHelper = require('utils/configs/config_property_helper');
 
 App.config = Em.Object.create({
 
@@ -588,98 +587,6 @@ App.config = Em.Object.create({
   },
 
   /**
-   * render configs, distribute them by service
-   * and wrap each in ServiceConfigProperty object
-   * @param configs
-   * @param storedConfigs
-   * @param allSelectedServiceNames
-   * @param installedServiceNames
-   * @param localDB
-   * @return {App.ServiceConfig[]}
-   */
-  renderConfigs: function (configs, storedConfigs, allSelectedServiceNames, installedServiceNames, localDB) {
-    var renderedServiceConfigs = [];
-    var services = [];
-
-    this.get('preDefinedServiceConfigs').forEach(function (serviceConfig) {
-      var serviceName = serviceConfig.get('serviceName');
-      if (allSelectedServiceNames.contains(serviceName) || serviceName === 'MISC') {
-        if (!installedServiceNames.contains(serviceName) || serviceName === 'MISC') {
-          serviceConfig.set('showConfig', true);
-        }
-        services.push(serviceConfig);
-      }
-    });
-    services.forEach(function (service) {
-      var configsByService = [];
-      var serviceConfigs = configs.filterProperty('serviceName', service.get('serviceName'));
-      serviceConfigs.forEach(function (_config) {
-        var serviceConfigProperty = App.ServiceConfigProperty.create(_config);
-        this.updateHostOverrides(serviceConfigProperty, _config);
-        if (!storedConfigs && !serviceConfigProperty.get('hasInitialValue')) {
-          configPropertyHelper.initialValue(serviceConfigProperty, localDB, configs);
-        }
-        serviceConfigProperty.validate();
-        configsByService.pushObject(serviceConfigProperty);
-      }, this);
-      var serviceConfig = this.createServiceConfig(service.get('serviceName'));
-      serviceConfig.set('showConfig', service.get('showConfig'));
-      serviceConfig.set('configs', configsByService);
-      this.addHostNamesToConfigs(serviceConfig, localDB.masterComponentHosts, localDB.slaveComponentHosts);
-      renderedServiceConfigs.push(serviceConfig);
-    }, this);
-    return renderedServiceConfigs;
-  },
-
-  /**
-   * Add host name properties to appropriate categories (for installer only)
-   * @param serviceConfig
-   * @param masterComponents
-   * @param slaveComponents
-   */
-  addHostNamesToConfigs: function(serviceConfig, masterComponents, slaveComponents) {
-    serviceConfig.get('configCategories').forEach(function(c) {
-      if (c.showHost) {
-        var value = [];
-        var componentName = c.name;
-        var masters = masterComponents.filterProperty('component', componentName);
-        if (masters.length) {
-          value = masters.mapProperty('hostName');
-        } else {
-          var slaves = slaveComponents.findProperty('componentName', componentName);
-          if (slaves) {
-            value = slaves.hosts.mapProperty('hostName');
-          }
-        }
-        var stackComponent = App.StackServiceComponent.find(componentName);
-        var hProperty = this.createHostNameProperty(serviceConfig.get('serviceName'), componentName, value, stackComponent);
-        serviceConfig.get('configs').push(App.ServiceConfigProperty.create(hProperty));
-      }
-    }, this);
-  },
-
-  /**
-   * create new child configs from overrides, attach them to parent config
-   * override - value of config, related to particular host(s)
-   * @param configProperty
-   * @param storedConfigProperty
-   */
-  updateHostOverrides: function (configProperty, storedConfigProperty) {
-    if (storedConfigProperty.overrides != null && storedConfigProperty.overrides.length > 0) {
-      var overrides = [];
-      storedConfigProperty.overrides.forEach(function (overrideEntry) {
-        // create new override with new value
-        var newSCP = App.ServiceConfigProperty.create(configProperty);
-        newSCP.set('value', overrideEntry.value);
-        newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
-        newSCP.set('parentSCP', configProperty);
-        overrides.pushObject(newSCP);
-      });
-      configProperty.set('overrides', overrides);
-    }
-  },
-
-  /**
    * create new ServiceConfig object by service name
    * @param {string} serviceName
    * @param {App.ServiceConfigGroup[]} configGroups

http://git-wip-us.apache.org/repos/asf/ambari/blob/d2062484/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 40e6124..f537f63 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1192,15 +1192,15 @@ describe('App.InstallerStep7Controller', function () {
     });
 
     afterEach(function () {
-      App.config.renderConfigs.restore();
+      installerStep7Controller.renderConfigs.restore();
     });
 
-    it('if wizard isn\'t addService, should set output of App.config.renderConfigs', function () {
+    it('if wizard isn\'t addService, should set output of installerStep7Controller.renderConfigs', function () {
       var serviceConfigs = Em.A([
         {serviceName:'HDFS', configs: []},
         {}
       ]);
-      sinon.stub(App.config, 'renderConfigs', function () {
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
         return serviceConfigs;
       });
       installerStep7Controller.set('wizardController.name', 'installerController');
@@ -1212,7 +1212,7 @@ describe('App.InstallerStep7Controller', function () {
       var serviceConfigs = Em.A([Em.Object.create({serviceName: 'HDFS', configs: []}), Em.Object.create({serviceName: 's2'})]);
       installerStep7Controller.set('wizardController.name', 'addServiceController');
       installerStep7Controller.reopen({selectedServiceNames: ['s2']});
-      sinon.stub(App.config, 'renderConfigs', function () {
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
         return serviceConfigs;
       });
       installerStep7Controller.setStepConfigs([], []);
@@ -1242,7 +1242,7 @@ describe('App.InstallerStep7Controller', function () {
       );
       installerStep7Controller.set('wizardController.name', 'addServiceController');
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
-      sinon.stub(App.config, 'renderConfigs', function () {
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
         return serviceConfigs;
       });
       installerStep7Controller.setStepConfigs([], []);
@@ -1270,7 +1270,7 @@ describe('App.InstallerStep7Controller', function () {
       );
 
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
-      sinon.stub(App.config, 'renderConfigs', function () {
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
         return serviceConfigs;
       });
       installerStep7Controller.setStepConfigs([], []);
@@ -1300,7 +1300,7 @@ describe('App.InstallerStep7Controller', function () {
 
       installerStep7Controller.reopen({selectedServiceNames: ['HDFS', 's2']});
       installerStep7Controller.set('installedServiceNames',['HDFS', 's2', 's3']);
-      sinon.stub(App.config, 'renderConfigs', function () {
+      sinon.stub(installerStep7Controller, 'renderConfigs', function () {
         return serviceConfigs;
       });
       installerStep7Controller.setStepConfigs([], []);