ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-7785 Principal for DRPC should point to Nimbus host.(Ievgen Fialkovskyi via atkach)
Date Wed, 15 Oct 2014 12:19:15 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 6a1d8de51 -> 9321b1d12


AMBARI-7785 Principal for DRPC should point to Nimbus host.(Ievgen Fialkovskyi via atkach)


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

Branch: refs/heads/branch-1.7.0
Commit: 9321b1d12e91e3ddf0671dbf396cc92f939c1c89
Parents: 6a1d8de
Author: atkach <atkach@hortonworks.com>
Authored: Wed Oct 15 15:19:02 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Wed Oct 15 15:19:02 2014 +0300

----------------------------------------------------------------------
 .../main/admin/security/add/step3.js            | 119 +++++++++----------
 .../main/admin/security/add/step3_test.js       |  95 +++++++++------
 2 files changed, 113 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9321b1d1/ambari-web/app/controllers/main/admin/security/add/step3.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/security/add/step3.js b/ambari-web/app/controllers/main/admin/security/add/step3.js
index 7afa51f..d967018 100644
--- a/ambari-web/app/controllers/main/admin/security/add/step3.js
+++ b/ambari-web/app/controllers/main/admin/security/add/step3.js
@@ -25,30 +25,35 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   hosts: [],
   isLoaded: false,
 
-  componentToUserMap: {
-    'NAMENODE': 'hdfs_user',
-    'SECONDARY_NAMENODE': 'hdfs_user',
-    'DATANODE': 'hdfs_user',
-    'JOURNALNODE': 'hdfs_user',
-    'TASKTRACKER': 'mapred_user',
-    'JOBTRACKER': 'mapred_user',
-    'HISTORYSERVER': 'mapred_user',
-    'RESOURCEMANAGER': 'yarn_user',
-    'NODEMANAGER': 'yarn_user',
-    'ZOOKEEPER_SERVER': 'zk_user',
-    'HIVE_SERVER': 'hive_user',
-    'OOZIE_SERVER': 'oozie_user',
-    'NAGIOS_SERVER': 'nagios_user',
-    'HBASE_MASTER': 'hbase_user',
-    'HBASE_REGIONSERVER': 'hbase_user',
-    'SUPERVISOR': 'storm_user',
-    'NIMBUS': 'storm_user',
-    'STORM_UI_SERVER': 'storm_user',
-    'FALCON_SERVER': 'falcon_user'
-  },
+  componentToUserMap: function() {
+    var map = {
+      'NAMENODE': 'hdfs_user',
+      'SECONDARY_NAMENODE': 'hdfs_user',
+      'DATANODE': 'hdfs_user',
+      'JOURNALNODE': 'hdfs_user',
+      'TASKTRACKER': 'mapred_user',
+      'JOBTRACKER': 'mapred_user',
+      'HISTORYSERVER': 'mapred_user',
+      'RESOURCEMANAGER': 'yarn_user',
+      'NODEMANAGER': 'yarn_user',
+      'ZOOKEEPER_SERVER': 'zk_user',
+      'HIVE_SERVER': 'hive_user',
+      'OOZIE_SERVER': 'oozie_user',
+      'NAGIOS_SERVER': 'nagios_user',
+      'HBASE_MASTER': 'hbase_user',
+      'HBASE_REGIONSERVER': 'hbase_user',
+      'SUPERVISOR': 'storm_user',
+      'NIMBUS': 'storm_user',
+      'STORM_UI_SERVER': 'storm_user',
+      'FALCON_SERVER': 'falcon_user'
+    };
+    if (App.get('isHadoop22Stack')) {
+      map['DRPC_SERVER'] = 'storm_user'
+    }
+    return map;
+  }.property('App.isHadoop22Stack'),
   // The componentName, principal, and keytab have to coincide with the values in secure_properties.js
-  componentToConfigMap: function () {
-    var hdp2map = [
+  componentToConfigMap: [
       {
         componentName: 'NAMENODE',
         principal: 'hadoop_http_principal_name',
@@ -126,18 +131,7 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
         displayName: Em.I18n.t('admin.addSecurity.user.yarn.atsHTTPUser'),
         isHadoop2Stack: true
       }
-    ];
-    if (App.get('isHadoop22Stack')) {
-      hdp2map.push({
-        componentName: 'DRPC_SERVER',
-        principal: 'nimbus_principal_name',
-        keytab: 'nimbus_keytab',
-        displayName: 'DRPC_SERVER',
-        isHadoop2Stack: true
-      });
-    }
-    return hdp2map;
-  }.property('App.isHadoop22Stack'),
+  ],
 
   mandatoryConfigs: [
     {
@@ -158,22 +152,6 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
       checkService: 'HBASE'
     }
   ],
-  /**
-   * mock users that used in testMode
-   */
-  testModeUsers: [
-    { name: 'hdfs_user', value: 'hdfs'},
-    { name: 'mapred_user', value: 'mapred'},
-    { name: 'yarn_user', value: 'yarn'},
-    { name: 'hbase_user', value: 'hbase'},
-    { name: 'hive_user', value: 'hive'},
-    { name: 'falcon_user', value: 'falcon'},
-    { name: 'smokeuser', value: 'ambari-qa'},
-    { name: 'zk_user', value: 'zookeeper'},
-    { name: 'oozie_user', value: 'oozie'},
-    { name: 'nagios_user', value: 'nagios'},
-    { name: 'user_group', value: 'hadoop'}
-  ],
 
   /**
    * download CSV file
@@ -263,6 +241,18 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
   },
 
   /**
+   * Returns host name for Nimbus component
+   */
+  getNimbusHostName: function () {
+    var host = this.get('hosts').find(function (host) {
+      return !!host.get('hostComponents').findProperty('componentName', 'NIMBUS');
+    });
+    if (host) {
+      return host.get('hostName');
+    }
+  },
+
+  /**
    * build map of connections between component and user
    * @param securityUsers
    */
@@ -270,7 +260,9 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     var componentToUserMap = this.get('componentToUserMap');
     var componentToOwnerMap = {};
     for (var component in componentToUserMap) {
-      componentToOwnerMap[component] = securityUsers.findProperty('name', componentToUserMap[component]).value;
+      var user = componentToUserMap[component];
+      var secutityUser = securityUsers.findProperty('name', user);
+      componentToOwnerMap[component] = secutityUser.value;
     }
     return componentToOwnerMap;
   },
@@ -359,6 +351,9 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     var componentsToDisplay = ['NAMENODE', 'SECONDARY_NAMENODE', 'DATANODE', 'JOBTRACKER',
'ZOOKEEPER_SERVER', 'HIVE_SERVER', 'TASKTRACKER',
       'OOZIE_SERVER', 'NAGIOS_SERVER', 'HBASE_MASTER', 'HBASE_REGIONSERVER', 'HISTORYSERVER',
'RESOURCEMANAGER', 'NODEMANAGER', 'JOURNALNODE',
       'SUPERVISOR', 'NIMBUS', 'STORM_UI_SERVER', 'FALCON_SERVER'];
+    if (App.get('isHadoop22Stack')) {
+      componentsToDisplay.push('DRPC_SERVER');
+    }
     var configs = this.get('content.serviceConfigProperties');
     var componentToOwnerMap = this.buildComponentToOwnerMap(securityUsers);
     var hostName = host.get('hostName');
@@ -369,7 +364,11 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     host.get('hostComponents').forEach(function (hostComponent) {
       if (componentsToDisplay.contains(hostComponent.get('componentName'))) {
         var serviceConfigs = configs.filterProperty('serviceName', hostComponent.get('service.serviceName'));
-        var secureProperties = this.getSecureProperties(serviceConfigs, hostComponent.get('componentName'),
hostName);
+        var targetHost = hostName;
+        if (App.get('isHadoop22Stack') && hostComponent.get('componentName') ===
'DRPC_SERVER') {
+          targetHost = this.getNimbusHostName()
+        }
+        var secureProperties = this.getSecureProperties(serviceConfigs, hostComponent.get('componentName'),
targetHost);
         var displayName = this.changeDisplayName(hostComponent.get('displayName'));
         var key = hostName + "--" + secureProperties.principal;
 
@@ -433,19 +432,7 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
    * @return {Array}
    */
   getSecurityUsers: function () {
-    var securityUsers = [];
-    if (App.get('testMode')) {
-      this.get('testModeUsers').forEach(function (user) {
-        securityUsers.push({
-          id: 'puppet var',
-          name: user.name,
-          value: user.value
-        });
-      });
-    } else {
-      securityUsers = App.db.getSecureUserInfo();
-    }
-    return securityUsers;
+    return App.db.getSecureUserInfo();
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/9321b1d1/ambari-web/test/controllers/main/admin/security/add/step3_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/security/add/step3_test.js b/ambari-web/test/controllers/main/admin/security/add/step3_test.js
index d06d00d..e84f649 100644
--- a/ambari-web/test/controllers/main/admin/security/add/step3_test.js
+++ b/ambari-web/test/controllers/main/admin/security/add/step3_test.js
@@ -101,17 +101,31 @@ describe('App.MainAdminSecurityAddStep3Controller', function () {
   });
 
   describe('#buildComponentToOwnerMap()', function() {
+    beforeEach(function(){
+      sinon.stub(controller, 'getSecurityUsers', function () {
+        return [{
+          name: 'storm_user',
+          value: 'storm'
+        }];
+      });
+    });
+    afterEach(function(){
+      controller.getSecurityUsers.restore();
+    });
+
     it('componentToUserMap is empty', function() {
-      controller.set('componentToUserMap', {});
+      sinon.stub(controller, 'get').withArgs('componentToUserMap').returns({});
       expect(controller.buildComponentToOwnerMap([])).to.eql({});
+      controller.get.restore();
     });
     it('componentToUserMap has properties', function() {
-      controller.set('componentToUserMap', {'COMP1': 'config1'});
       var securityUsers = [{
         name: 'config1',
         value: 'value1'
       }];
+      sinon.stub(controller, 'get').withArgs('componentToUserMap').returns({'COMP1': 'config1'});
       expect(controller.buildComponentToOwnerMap(securityUsers)).to.eql({'COMP1': 'value1'});
+      controller.get.restore();
     });
   });
 
@@ -341,6 +355,50 @@ describe('App.MainAdminSecurityAddStep3Controller', function () {
     });
   });
 
+  describe('#setHostComponentsSecureValue()', function () {
+
+    it('DRPC Server principal should point to Nimbus host for HDP-2.2 stack', function ()
{
+      sinon.stub(App, 'get').withArgs('isHadoop22Stack').returns(true);
+      sinon.stub(controller, 'get').withArgs('content.serviceConfigProperties').returns([]);
+      sinon.stub(controller, 'getNimbusHostName').returns('nimbus_host');
+      sinon.stub(controller, 'buildComponentToOwnerMap').returns({'DRPC_SERVER': 'storm'});
+      sinon.stub(controller, 'getSecureProperties').returns({
+        "keytab": "/etc/security/keytabs/nimbus.service.keytab",
+        "principal": "nimbus/nimbus_host"
+      });
+      sinon.stub(controller, 'getSecurityUsers', function () {
+        return [
+          {
+            name: 'storm_user',
+            value: 'storm'
+          }
+        ];
+      });
+      var host = Em.Object.create({
+        hostComponents: [Em.Object.create({
+          componentName: 'DRPC_SERVER',
+          displayName: 'DRPC Server'
+        })]
+      });
+
+      var result = [];
+      controller.setHostComponentsSecureValue(result, host, {}, [], 'hadoopId');
+      expect(result).to.be.not.empty;
+      expect(controller.getSecureProperties.args[0][2]).to.equal('nimbus_host');
+
+      var hostComponent = result[0];
+      expect(hostComponent.principal).to.equal('nimbus/nimbus_host');
+      expect(hostComponent.owner).to.equal('storm');
+
+      App.get.restore();
+      controller.get.restore();
+      controller.getNimbusHostName.restore();
+      controller.buildComponentToOwnerMap.restore();
+      controller.getSecureProperties.restore();
+      controller.getSecurityUsers.restore();
+    });
+  });
+
   describe('#getSecureProperties()', function () {
 
     beforeEach(function () {
@@ -522,37 +580,4 @@ describe('App.MainAdminSecurityAddStep3Controller', function () {
       expect(controller.changeDisplayName('something')).to.equal('something');
     });
   });
-
-  describe('#getSecurityUsers()', function () {
-    it('testMode is true, testModeUsers is empty', function () {
-      controller.set('testModeUsers', []);
-      App.testMode = true;
-      expect(controller.getSecurityUsers()).to.eql([]);
-    });
-    it('testMode is true, testModeUsers is correct', function () {
-      controller.set('testModeUsers', [
-        {
-          name: 'user1',
-          value: 'value1'
-        }
-      ]);
-      App.testMode = true;
-      expect(controller.getSecurityUsers()).to.eql([
-        {
-          id: 'puppet var',
-          name: 'user1',
-          value: 'value1'
-        }
-      ]);
-    });
-    it('testMode is false', function () {
-      sinon.stub(App.db, 'getSecureUserInfo', function () {
-        return [{}];
-      });
-      App.testMode = false;
-      expect(controller.getSecurityUsers()).to.eql([{}]);
-      expect(App.db.getSecureUserInfo.calledOnce).to.be.true;
-      App.db.getSecureUserInfo.restore();
-    });
-  });
 });


Mime
View raw message