浏览代码

AMBARI-6542 UI should add security properties to different *-env. (ababiichuk)

aBabiichuk 11 年之前
父节点
当前提交
13464cad00

+ 2 - 2
ambari-web/app/controllers/main/admin/security.js

@@ -99,8 +99,8 @@ App.MainAdminSecurityController = Em.Controller.extend({
     this.loadSecurityUsers();
     //loadSecurityUsers - desired configs fetched from server
     step2Controller.addUserPrincipals(services, this.get('securityUsers'));
-    step2Controller.addMasterHostToGlobals();
-    step2Controller.addSlaveHostToGlobals();
+    step2Controller.addMasterHostToConfigs();
+    step2Controller.addSlaveHostToConfigs();
     this.renderServiceConfigs(services);
     step2Controller.changeCategoryOnHa(services, this.get('stepConfigs'));
 

+ 6 - 6
ambari-web/app/controllers/main/admin/security/add/step2.js

@@ -198,9 +198,9 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
     this.clearStep();
     this.loadUsers();
     this.addUserPrincipals(this.get('content.services'), this.get('securityUsers'));
-    this.addMasterHostToGlobals();
+    this.addMasterHostToConfigs();
     this.addHostPrincipals();
-    this.addSlaveHostToGlobals();
+    this.addSlaveHostToConfigs();
     this.renderServiceConfigs(this.get('content.services'));
     this.changeCategoryOnHa(this.get('content.services'), this.get('stepConfigs'));
     this.setStoredConfigsValue(this.get('content.serviceConfigProperties'));
@@ -368,18 +368,18 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
   },
 
   /**
-   * put hosts of slave component into defaultValue of global configs
+   * put hosts of slave component into defaultValue of configs
    */
-  addSlaveHostToGlobals: function () {
+  addSlaveHostToConfigs: function () {
     this.get('slaveComponentMap').forEach(function (service) {
       this.setHostsToConfig(service.serviceName, service.configName, [service.component]);
     }, this);
   },
 
   /**
-   * put hosts of master component into defaultValue of global configs
+   * put hosts of master component into defaultValue of configs
    */
-  addMasterHostToGlobals: function () {
+  addMasterHostToConfigs: function () {
     this.get('masterComponentMap').forEach(function (item) {
       this.setHostsToConfig(item.serviceName, item.configName, item.components);
     }, this);

+ 49 - 65
ambari-web/app/controllers/main/admin/security/add/step4.js

@@ -25,7 +25,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   serviceUsersBinding: 'App.router.mainAdminSecurityController.serviceUsers',
 
   /**
-   * component configs which should be added to global
+   * component configs which should be added to configs
    */
   componentsConfig: [
     {
@@ -200,7 +200,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
       if (_config.hasOwnProperty('dependedServiceName')) {
         value = this.checkServiceForConfigValue(value, _config.dependedServiceName);
       }
-      value = this.getGlobConfigValue(_config.templateName, value);
+      value = this.getConfigValue(_config.templateName, value);
       uiConfig.push({
         "id": "site property",
         "name": _config.name,
@@ -245,24 +245,24 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
    * @param expression
    * @return {String|null}
    */
-  getGlobConfigValue: function (templateName, expression) {
+  getConfigValue: function (templateName, expression) {
     var express = expression.match(/<(.*?)>/g);
     var value = expression;
     if (Em.isNone(express)) return expression;
 
     express.forEach(function (_express) {
       var index = parseInt(_express.match(/\[([\d]*)(?=\])/)[1]);
-      var globalConfig = this.get('globalProperties').findProperty('name', templateName[index]);
+      var configs = this.get('configs').findProperty('name', templateName[index]);
 
       if (!!value) {
-        value = (globalConfig) ? value.replace(_express, globalConfig.value) : null;
+        value = (configs) ? value.replace(_express, configs.value) : null;
       }
     }, this);
     return value;
   },
 
   /**
-   * format name of config values of global configs which match foreignKey
+   * format name of config values of configs which match foreignKey
    * @param uiConfig
    * @param config
    * @return {Boolean}
@@ -274,13 +274,13 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
     if (fkValue) {
       fkValue.forEach(function (_fkValue) {
         var index = parseInt(_fkValue.match(/\[([\d]*)(?=\])/)[1]);
-        var globalValue;
+        var value;
         if (uiConfig.someProperty('name', config.foreignKey[index])) {
-          globalValue = uiConfig.findProperty('name', config.foreignKey[index]).value;
-          config._name = config.name.replace(_fkValue, globalValue);
-        } else if (this.get('globalProperties').someProperty('name', config.foreignKey[index])) {
-          globalValue = this.get('globalProperties').findProperty('name', config.foreignKey[index]).value;
-          config._name = config.name.replace(_fkValue, globalValue);
+          value = uiConfig.findProperty('name', config.foreignKey[index]).value;
+          config._name = config.name.replace(_fkValue, value);
+        } else if (this.get('configs').someProperty('name', config.foreignKey[index])) {
+          value = this.get('configs').findProperty('name', config.foreignKey[index]).value;
+          config._name = config.name.replace(_fkValue, value);
         }
       }, this);
       return true;
@@ -289,7 +289,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   },
 
   /**
-   * Set config value with values of global configs which match template
+   * Set config value with values of configs which match template
    * @param config
    * @return {Boolean}
    */
@@ -301,9 +301,9 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
     if (templateValue) {
       templateValue.forEach(function (_value) {
         var index = parseInt(_value.match(/\[([\d]*)(?=\])/)[1]);
-        var globValue = this.get('globalProperties').findProperty('name', config.templateName[index]);
+        var cfgValue = this.get('configs').findProperty('name', config.templateName[index]);
 
-        config.value = (globValue) ? config.value.replace(_value, globValue.value) : null;
+        config.value = (cfgValue) ? config.value.replace(_value, cfgValue.value) : null;
       }, this);
       return true;
     }
@@ -314,33 +314,26 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
    * prepare secure configs
    */
   prepareSecureConfigs: function () {
-    this.loadGlobals();
-    var storedConfigs = this.get('content.serviceConfigProperties').filterProperty('id', 'site property');
+    var configs = this.get('content.serviceConfigProperties');
+    this.set('configs', configs);
+    this.loadStaticConfigs(); //Hack for properties which are declared in site_properties.js and not able to retrieve values declared in secure_properties.js
+    this.loadUsersToConfigs();
+    this.loadHostNames();
+    this.loadPrimaryNames();
     var uiConfigs = this.loadUiSideConfigs();
-    this.set('configs', storedConfigs.concat(uiConfigs));
+    this.set('configs', this.get('configs').concat(uiConfigs));
   },
 
-  /**
-   * load global configs
-   */
-  loadGlobals: function () {
-    var globals = this.get('content.serviceConfigProperties').filterProperty('id', 'puppet var');
-    this.set('globalProperties', globals);
-    this.loadStaticGlobal(); //Hack for properties which are declared in global_properties.js and not able to retrieve values declared in secure_properties.js
-    this.loadUsersToGlobal();
-    this.loadHostNamesToGlobal();
-    this.loadPrimaryNamesToGlobals();
-  },
 
   /**
-   * push users to global configs
+   * push users to configs
    */
-  loadUsersToGlobal: function () {
+  loadUsersToConfigs: function () {
     if (!this.get('serviceUsers').length)  {
       this.loadUsersFromServer();
     }
     App.router.get('mainAdminSecurityController.serviceUsers').forEach(function (_user) {
-      this.get('globalProperties').pushObject(_user);
+      this.get('configs').pushObject(_user);
     }, this);
   },
 
@@ -359,7 +352,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
       var hostComponent = service.get('hostComponents').findProperty('componentName', componentName);
       if (hostComponent) {
         var hostName = hostComponent.get('hostName');
-        this.get('globalProperties').push({
+        this.get('configs').push({
           id: 'puppet var',
           name: configName,
           value: hostName
@@ -371,9 +364,9 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   },
 
   /**
-   * add hosts' names to global configs
+   * add hosts' names to configs
    */
-  loadHostNamesToGlobal: function () {
+  loadHostNames: function () {
     var componentsConfig = this.get('componentsConfig');
     componentsConfig.forEach(function (host) {
       this.addHostConfig(host.serviceName, host.componentName, host.configName);
@@ -381,10 +374,10 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   },
 
   /**
-   * load static global
+   * load static configs
    */
-  loadStaticGlobal: function () {
-    this.get('globalProperties').forEach(function (_property) {
+  loadStaticConfigs: function () {
+    this.get('configs').forEach(function (_property) {
       switch (_property.name) {
         case 'security_enabled':
           _property.value = 'true';
@@ -394,26 +387,26 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   },
 
   /**
-   * add principals to global properties
+   * add principals to properties
    */
-  loadPrimaryNamesToGlobals: function () {
+  loadPrimaryNames: function () {
     var principalProperties = this.getPrincipalNames();
     principalProperties.forEach(function (_principalProperty) {
       var name = _principalProperty.name.replace('principal', 'primary');
       var value = _principalProperty.value.split('/')[0];
-      this.get('globalProperties').push({name: name, value: value});
+      this.get('configs').push({name: name, value: value});
     }, this);
   },
 
   /**
-   * gather and return global properties with "principal_name"
+   * gather and return properties with "principal_name"
    * @return {Array}
    */
   getPrincipalNames: function () {
     var principalNames = [];
-    this.get('globalProperties').forEach(function (_globalProperty) {
-      if (/principal_name?$/.test(_globalProperty.name)) {
-        principalNames.push(_globalProperty);
+    this.get('configs').forEach(function (_property) {
+      if (/principal_name?$/.test(_property.name)) {
+        principalNames.push(_property);
       }
     }, this);
     this.get('secureProperties').forEach(function (_secureProperty) {
@@ -450,27 +443,18 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   manageSecureConfigs: function () {
     var serviceConfigTags = this.get('serviceConfigTags');
     var secureConfigs = this.get('secureConfigs');
-    var siteProperties = this.get('configs').filterProperty('id', 'site property');
-    var globalProperties = this.get('globalProperties');
-
+    var siteProperties = this.get('configs');
     if (serviceConfigTags) {
+      secureConfigs.forEach(function (config) {
+        this.setPrincipalValue(config.serviceName, config.name);
+      }, this);
       serviceConfigTags.forEach(function (_serviceConfigTags) {
         _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
-
-        if (_serviceConfigTags.siteName === 'global') {
-          secureConfigs.forEach(function (config) {
-            this.setPrincipalValue(config.serviceName, config.name);
-          }, this);
-          globalProperties.forEach(function (_globalProperty) {
-            if (!/_hosts?$/.test(_globalProperty.name)) {
-              _serviceConfigTags.configs[_globalProperty.name] = _globalProperty.value;
-            }
-          }, this);
-        } else {
-          siteProperties.filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
+        siteProperties.filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
+          if (!/_hosts?$/.test(_config.name)) {
             _serviceConfigTags.configs[_config.name] = _config.value;
-          }, this);
-        }
+          }
+        }, this);
       }, this);
       return true;
     } else {
@@ -489,11 +473,11 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
    * @return {Boolean}
    */
   setPrincipalValue: function (serviceName, principalName) {
-    var globalProperties = this.get('globalProperties');
-    var realmName = globalProperties.findProperty('name', 'kerberos_domain');
+    var siteProperties = this.get('configs');
+    var realmName = siteProperties.findProperty('name', 'kerberos_domain');
 
     if (this.get('secureServices').someProperty('serviceName', serviceName)) {
-      var principalProperty = globalProperties.findProperty('name', principalName);
+      var principalProperty = siteProperties.findProperty('name', principalName);
       principalProperty.value = principalProperty.value + '@' + realmName.value;
       return true;
     }

+ 4 - 4
ambari-web/app/controllers/main/admin/security/disable.js

@@ -146,8 +146,8 @@ App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController
     } else {
       serviceConfigTags.forEach(function (_serviceConfigTags) {
         _serviceConfigTags.newTagName = 'version' + (new Date).getTime();
-        if (_serviceConfigTags.siteName === 'hadoop-env') {
-          this.deleteDisabledGlobalConfigs(secureProperties, _serviceConfigTags);
+        if (_serviceConfigTags.siteName.contains('-env')) {
+          this.deleteDisabledConfigs(secureProperties, _serviceConfigTags);
           _serviceConfigTags.configs.security_enabled = 'false';
         } else {
           this.modifySiteConfigs(secureMapping, _serviceConfigTags);
@@ -157,12 +157,12 @@ App.MainAdminSecurityDisableController = App.MainAdminSecurityProgressController
     }
   },
   /**
-   * delete global configs, which aren't required when security disabled
+   * delete configs, which aren't required when security disabled
    * @param secureProperties
    * @param _serviceConfigTags
    * @return {Boolean}
    */
-  deleteDisabledGlobalConfigs: function (secureProperties, _serviceConfigTags) {
+  deleteDisabledConfigs: function (secureProperties, _serviceConfigTags) {
     if (!secureProperties || !_serviceConfigTags) return false;
     secureProperties.forEach(function (_config) {
       if (_config.name in _serviceConfigTags.configs) {

+ 0 - 1
ambari-web/app/controllers/main/admin/security/security_progress_controller.js

@@ -24,7 +24,6 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
   commands: [],
   configs: [],
   serviceConfigTags: [],
-  globalProperties: [],
   totalSteps: 3,
   isSubmitDisabled: true,
   hasHostPopup: true,

+ 1 - 1
ambari-web/app/data/HDP2/secure_configs.js

@@ -31,7 +31,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'KERBEROS', displayName: 'Kerberos'}),
       App.ServiceConfigCategory.create({ name: 'AMBARI', displayName: 'Ambari'})
     ],
-    sites: ['global'],
+    sites: ['hadoop-env', 'oozie-env', 'nagios-env', 'zookeeper-env', 'storm-env', 'hbase-env'],
     configs: configProperties.filterProperty('serviceName', 'GENERAL')
   },
   {

+ 12 - 0
ambari-web/app/data/HDP2/secure_properties.js

@@ -28,6 +28,7 @@ module.exports =
       "isVisible": false,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "KERBEROS"
     },
     {
@@ -66,6 +67,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "KERBEROS"
     },
     {
@@ -106,6 +108,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "AMBARI"
     },
     {
@@ -133,6 +136,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "AMBARI"
     },
     {
@@ -160,6 +164,7 @@ module.exports =
       "isVisible": false,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hbase-env.xml",
       "category": "AMBARI"
     },
 
@@ -806,6 +811,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "OOZIE",
+      "filename": "oozie-env.xml",
       "category": "Oozie Server",
       "component": "OOZIE_SERVER"
     },
@@ -861,6 +867,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "ZOOKEEPER",
+      "filename": "zookeeper-env.xml",
       "category": "ZooKeeper Server",
       "component": "ZOOKEEPER_SERVER"
     },
@@ -875,6 +882,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "ZOOKEEPER",
+      "filename": "zookeeper-env.xml",
       "category": "ZooKeeper Server",
       "component": "ZOOKEEPER_SERVER"
     },
@@ -904,6 +912,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "NAGIOS",
+      "filename": "nagios-env.xml",
       "category": "Nagios Server",
       "component": "NAGIOS_SERVER"
     },
@@ -918,6 +927,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "NAGIOS",
+      "filename": "nagios-env.xml",
       "category": "Nagios Server",
       "component": "NAGIOS_SERVER"
     },
@@ -946,6 +956,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "STORM",
+      "filename": "storm-env.xml",
       "category": "Storm Topology",
       "components": ["SUPERVISOR", "NIMBUS", "STORM_UI_SERVER"]
     },
@@ -960,6 +971,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "STORM",
+      "filename": "storm-env.xml",
       "category": "Storm Topology",
       "components": ["SUPERVISOR", "NIMBUS"]
     },

+ 1 - 1
ambari-web/app/data/secure_configs.js

@@ -31,7 +31,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'KERBEROS', displayName: 'Kerberos'}),
       App.ServiceConfigCategory.create({ name: 'AMBARI', displayName: 'Ambari'})
     ],
-    sites: ['global'],
+    sites: ['hadoop-env', 'oozie-env', 'nagios-env', 'zookeeper-env', 'storm-env', 'hbase-env'],
     configs: configProperties.filterProperty('serviceName', 'GENERAL')
   },
   {

+ 10 - 0
ambari-web/app/data/secure_properties.js

@@ -28,6 +28,7 @@ module.exports =
       "isVisible": false,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "KERBEROS"
     },
     {
@@ -66,6 +67,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "KERBEROS"
     },
     {
@@ -106,6 +108,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "AMBARI"
     },
     {
@@ -133,6 +136,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hadoop-env.xml",
       "category": "AMBARI"
     },
     {
@@ -160,6 +164,7 @@ module.exports =
       "isVisible": false,
       "isOverridable": false,
       "serviceName": "GENERAL",
+      "filename": "hbase-env.xml",
       "category": "AMBARI"
     },
 
@@ -684,6 +689,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "OOZIE",
+      "filename": "oozie-env.xml",
       "category": "Oozie Server",
       "component": "OOZIE_SERVER"
     },
@@ -739,6 +745,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "ZOOKEEPER",
+      "filename": "zookeeper-env.xml",
       "category": "ZooKeeper Server",
       "component": "ZOOKEEPER_SERVER"
     },
@@ -753,6 +760,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "ZOOKEEPER",
+      "filename": "zookeeper-env.xml",
       "category": "ZooKeeper Server",
       "component": "ZOOKEEPER_SERVER"
     },
@@ -781,6 +789,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "NAGIOS",
+      "filename": "nagios-env.xml",
       "category": "Nagios Server",
       "component": "NAGIOS_SERVER"
     },
@@ -795,6 +804,7 @@ module.exports =
       "isVisible": true,
       "isOverridable": false,
       "serviceName": "NAGIOS",
+      "filename": "nagios-env.xml",
       "category": "Nagios Server",
       "component": "NAGIOS_SERVER"
     }