ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject git commit: AMBARI-7826. On cluster with custom users for HDFS and HBase services has default names. (jaimin)
Date Fri, 17 Oct 2014 17:55:29 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk ec6b44eca -> 8162fd399


AMBARI-7826. On cluster with custom users for HDFS and HBase services has default names. (jaimin)


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

Branch: refs/heads/trunk
Commit: 8162fd399e4c52dec4bb3611f58486416345f231
Parents: ec6b44e
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Fri Oct 17 10:53:23 2014 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Fri Oct 17 10:54:59 2014 -0700

----------------------------------------------------------------------
 .../app/controllers/main/admin/security.js      | 94 ++++++++++++--------
 ambari-web/app/routes/add_security.js           |  6 +-
 .../controllers/main/admin/security_test.js     | 18 ++--
 3 files changed, 70 insertions(+), 48 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/8162fd39/ambari-web/app/controllers/main/admin/security.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security.js b/ambari-web/app/controllers/main/admin/security.js
index 5cd8a63..d5dd543 100644
--- a/ambari-web/app/controllers/main/admin/security.js
+++ b/ambari-web/app/controllers/main/admin/security.js
@@ -74,25 +74,25 @@ App.MainAdminSecurityController = Em.Controller.extend({
       }
     }, this);
     return services;
-  }.property(),
+  }.property('App.router.clusterController.isLoaded'),
 
   /**
    * default values of configs, which contains user names
    */
-  defaultUserNameMap: {
-    'hdfs_user': 'hdfs',
-    'yarn_user': 'yarn',
-    'mapred_user': 'mapred',
-    'hbase_user': 'hbase',
-    'hive_user': 'hive',
-    'proxyuser_group': 'users',
-    'smokeuser': 'ambari-qa',
-    'zk_user': 'zookeeper',
-    'oozie_user': 'oozie',
-    'nagios_user': 'nagios',
-    'user_group': 'hadoop',
-    'storm_user': 'storm',
-    'falcon_user': 'falcon'
+  userNameMap: {
+    'hdfs_user': {defaultValue: 'hdfs', siteName: 'hadoop-env', serviceName: 'HDFS'},
+    'yarn_user': {defaultValue: 'yarn', siteName: 'yarn-env', serviceName: 'YARN'},
+    'mapred_user': {defaultValue: 'mapred', siteName: 'mapred-env', serviceName: 'MAPREDUCE'},
+    'hbase_user': {defaultValue: 'hbase', siteName: 'hbase-env', serviceName: 'HBASE'},
+    'hive_user': {defaultValue: 'hive', siteName: 'hive-env', serviceName: 'HIVE'},
+    'proxyuser_group': {defaultValue: 'users', siteName: 'hadoop-env', serviceName: 'HDFS'},
+    'smokeuser': {defaultValue: 'ambari-qa', siteName: 'cluster-env', serviceName: 'CLUSTER'},
+    'zk_user': {defaultValue: 'zookeeper', siteName: 'zookeeper-env', serviceName: 'ZOOKEEPER'},
+    'oozie_user': {defaultValue: 'oozie', siteName: 'oozie-env', serviceName: 'OOZIE'},
+    'nagios_user': {defaultValue: 'nagios', siteName: 'nagios-env', serviceName: 'NAGIOS'},
+    'user_group': {defaultValue: 'hadoop', siteName: 'hadoop-env', serviceName: 'HDFS'},
+    'storm_user': {defaultValue: 'storm', siteName: 'storm-env', serviceName: 'STORM'},
+    'falcon_user': {defaultValue: 'falcon', siteName: 'falcon-env', serviceName: 'FALCON'}
   },
 
   loadStep: function () {
@@ -153,7 +153,6 @@ App.MainAdminSecurityController = Em.Controller.extend({
    * @return {Object}
    */
   setServiceTagNames: function (secureService, configs) {
-    //var serviceConfigTags = this.get('serviceConfigTags');
     for (var index in configs) {
       if (secureService.sites && secureService.sites.contains(index)) {
         var serviceConfigObj = {
@@ -274,33 +273,48 @@ App.MainAdminSecurityController = Em.Controller.extend({
 
   getSecurityStatusFromServerSuccessCallback: function (data) {
     var configs = data.Clusters.desired_configs;
-    var tags = [];
+    var serviceNames = this.get('services').mapProperty('serviceName');
+    var configTags = [];
     this.set('desiredConfigs', configs);
+    for (var key in this.userNameMap) {
+      if (serviceNames.contains(this.userNameMap[key]['serviceName']) || this.userNameMap[key]['serviceName']
=== 'CLUSTER')
+        configTags.push(this.userNameMap[key]['siteName']);
+    }
+    configTags = configTags.uniq();
 
-    if  ('cluster-env' in configs) {
-      this.set('tag.cluster-env', configs['cluster-env'].tag);
-      tags.pushObject({
-        siteName: "cluster-env",
-        tagName: this.get('tag.cluster-env')
-      });
-    } else {
+    var errorFlag = false;
+    configTags.forEach(function (_tag) {
+      if (!configs[_tag]) {
+        errorFlag = true;
+      }
+    }, this);
+
+    if (errorFlag) {
       this.showSecurityErrorPopup();
-    }
+    }  else {
+      var tags = configTags.map(function (_tag) {
+        this.set('tag.' + _tag, configs[_tag].tag);
+        return {
+          siteName: _tag,
+          tagName: configs[_tag].tag
+        }
+      }, this);
 
-    if ('hdfs-site' in configs) {
-      this.set('tag.hdfs-site', configs['hdfs-site'].tag);
-      tags.pushObject({
-        siteName: "hdfs-site",
-        tagName: this.get('tag.hdfs-site')
-      });
+      if ('hdfs-site' in configs) {
+        this.set('tag.hdfs-site', configs['hdfs-site'].tag);
+        tags.pushObject({
+          siteName: "hdfs-site",
+          tagName: this.get('tag.hdfs-site')
+        });
+      }
+      this.getServiceConfigsFromServer(tags);
     }
-    this.getServiceConfigsFromServer(tags);
   },
 
   getServiceConfigsFromServer: function (tags) {
     var self = this;
 
-    App.router.get('configurationController').getConfigsByTags(tags).done(function(data)
{
+    App.router.get('configurationController').getConfigsByTags(tags).done(function (data)
{
       var configs = data.findProperty('tag', self.get('tag.cluster-env')).properties;
       if (configs && (configs['security_enabled'] === 'true' || configs['security_enabled']
=== true)) {
         self.set('securityEnabled', true);
@@ -312,7 +326,11 @@ App.MainAdminSecurityController = Em.Controller.extend({
           self.setNnHaStatus(hdfsConfigs);
         }
       }
-      self.loadUsers(configs);
+      var userConfigs = {};
+      data.forEach(function(_config){
+        $.extend(userConfigs, _config.properties);
+      });
+      self.loadUsers(userConfigs);
       self.set('dataIsLoaded', true);
     });
   },
@@ -336,14 +354,14 @@ App.MainAdminSecurityController = Em.Controller.extend({
    * @param configs {Object}
    */
   loadUsers: function (configs) {
-    var defaultUserNameMap = this.get('defaultUserNameMap');
-    var serviceUsers = this.get('serviceUsers');
+    var defaultUserNameMap = this.get('userNameMap');
+    this.set('serviceUsers',[]);
 
     for (var configName in defaultUserNameMap) {
-      serviceUsers.push({
+      this.get('serviceUsers').push({
         id: 'puppet var',
         name: configName,
-        value: configs[configName] || defaultUserNameMap[configName]
+        value: configs[configName] || defaultUserNameMap[configName]['defaultValue']
       });
     }
     App.db.setSecureUserInfo(this.get('serviceUsers'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/8162fd39/ambari-web/app/routes/add_security.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_security.js b/ambari-web/app/routes/add_security.js
index fd43299..cca41a6 100644
--- a/ambari-web/app/routes/add_security.js
+++ b/ambari-web/app/routes/add_security.js
@@ -21,8 +21,8 @@ module.exports = App.WizardRoute.extend({
   route: '/addSecurity',
   enter: function (router) {
     console.log('in /security/add:enter');
-
-    Ember.run.next(function () {
+    var controller = router.get('addSecurityController');
+    controller.dataLoading().done(Ember.run.next(function () {
       //after refresh check if the wizard is open then restore it
       if (router.get('mainAdminSecurityController').getAddSecurityWizardStatus() === 'RUNNING')
{
         var mainAdminSecurityController = router.get('mainAdminSecurityController');
@@ -101,7 +101,7 @@ module.exports = App.WizardRoute.extend({
       } else {
         router.transitionTo('adminSecurity.index');
       }
-    });
+    }));
   },
 
   step1: Em.Route.extend({

http://git-wip-us.apache.org/repos/asf/ambari/blob/8162fd39/ambari-web/test/controllers/main/admin/security_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/security_test.js b/ambari-web/test/controllers/main/admin/security_test.js
index 121abb4..8557c6c 100644
--- a/ambari-web/test/controllers/main/admin/security_test.js
+++ b/ambari-web/test/controllers/main/admin/security_test.js
@@ -25,7 +25,8 @@ describe('App.MainAdminSecurityController', function () {
 
   var controller = App.MainAdminSecurityController.create({
     getServiceConfigsFromServer: function () {
-    }
+    } ,
+    services: [{serviceName: 'HDFS'}]
   });
 
   describe('#setServiceTagNames()', function () {
@@ -126,6 +127,9 @@ describe('App.MainAdminSecurityController', function () {
           },
           'cluster-env': {
             tag: 2
+          },
+          'hadoop-env': {
+            tag: 3
           }
         }
       }};
@@ -189,7 +193,7 @@ describe('App.MainAdminSecurityController', function () {
     it('if defaultUserNameMap is empty then serviceUsers stays the same', function () {
       var configs = {};
       controller.set('serviceUsers', []);
-      controller.set('defaultUserNameMap', {});
+      controller.set('userNameMap', {});
       controller.loadUsers(configs);
       expect(controller.get('serviceUsers')).to.be.empty;
     });
@@ -197,9 +201,9 @@ describe('App.MainAdminSecurityController', function () {
     it('if user config value is missing then use default', function () {
       var configs = {};
       controller.set('serviceUsers', []);
-      controller.set('defaultUserNameMap', {
-        'test_user': 'test'
-      });
+      controller.set('userNameMap', {
+        test_user: {defaultValue: 'test', siteName: 'test-env', serviceName: 'TEST'
+      }});
       controller.loadUsers(configs);
       expect(controller.get('serviceUsers')).to.eql([
         {
@@ -216,8 +220,8 @@ describe('App.MainAdminSecurityController', function () {
       };
       controller.set('serviceUsers', []);
       controller.set('defaultUserNameMap', {
-        'test_user': 'test'
-      });
+        test_user: {defaultValue: 'test', siteName: 'test-env', serviceName: 'TEST'
+        }});
       controller.loadUsers(configs);
       expect(controller.get('serviceUsers')).to.eql([
         {


Mime
View raw message