Pārlūkot izejas kodu

AMBARI-4972. Add generating Storm keytabs in csv to UI. (Denys Buzhor via onechiporenko)

Oleg Nechiporenko 11 gadi atpakaļ
vecāks
revīzija
02959df691

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

@@ -367,6 +367,11 @@ App.MainAdminSecurityController = Em.Controller.extend({
       name: 'user_group',
       value: configs['user_group'] ? configs['user_group'] : 'hadoop'
     });
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'storm_user',
+      value: configs['storm_user'] ? configs['storm_user'] : 'storm'
+    });
     App.db.setSecureUserInfo(serviceUsers);
   },
 

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

@@ -170,14 +170,36 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
   },
 
   addSlaveHostToGlobals: function (serviceConfigs) {
-    var hdfsService = serviceConfigs.findProperty('serviceName', 'HDFS');
-    var mapReduceService = serviceConfigs.findProperty('serviceName', 'MAPREDUCE');
-    var yarnService = serviceConfigs.findProperty('serviceName', 'YARN');
-    var hbaseService = serviceConfigs.findProperty('serviceName', 'HBASE');
-    this.setHostsToConfig(hdfsService, 'datanode_hosts', 'DATANODE');
-    this.setHostsToConfig(mapReduceService, 'tasktracker_hosts', 'TASKTRACKER');
-    this.setHostsToConfig(yarnService, 'nodemanager_host', 'NODEMANAGER');
-    this.setHostsToConfig(hbaseService, 'regionserver_hosts', 'HBASE_REGIONSERVER');
+    var serviceComponentMap = [
+      {
+        serviceName: 'HDFS',
+        configName: 'datanode_hosts',
+        component: 'DATANODE'
+      },
+      {
+        serviceName: 'MAPREDUCE',
+        configName: 'tasktracker_hosts',
+        component: 'TASKTRACKER'
+      },
+      {
+        serviceName: 'YARN',
+        configName: 'nodemanager_host',
+        component: 'NODEMANAGER'
+      },
+      {
+        serviceName: 'HBASE',
+        configName: 'regionserver_hosts',
+        component: 'HBASE_REGIONSERVER'
+      },
+      {
+        serviceName: 'STORM',
+        configName: 'supervisor_hosts',
+        component: 'SUPERVISOR'
+      }
+    ];
+    serviceComponentMap.forEach(function(service) {
+      this.setHostsToConfig(serviceConfigs.findProperty('serviceName', service.serviceName), service.configName, service.component);
+    }, this);
   },
 
   addMasterHostToGlobals: function (serviceConfigs) {
@@ -191,6 +213,8 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
     var mapReduceService = serviceConfigs.findProperty('serviceName', 'MAPREDUCE');
     var mapReduce2Service = serviceConfigs.findProperty('serviceName', 'MAPREDUCE2');
     var yarnService = serviceConfigs.findProperty('serviceName', 'YARN');
+    var stormService = serviceConfigs.findProperty('serviceName', 'STORM');
+
     if (oozieService) {
       var oozieServerHost = oozieService.configs.findProperty('name', 'oozie_servername');
       var oozieServerPrincipal = oozieService.configs.findProperty('name', 'oozie_principal_name');
@@ -262,6 +286,22 @@ App.MainAdminSecurityAddStep2Controller = Em.Controller.extend({
         resourceManagerHost.defaultValue = App.Service.find('YARN').get('hostComponents').findProperty('componentName', 'RESOURCEMANAGER').get('host.hostName');
       }
     }
+
+    if (stormService) {
+      var stormMasterComponents = [
+        {
+          configName: 'storm_ui_server_host',
+          componentName: 'STORM_UI_SERVER'
+        },
+        {
+          configName: 'nimbus_host',
+          componentName: 'NIMBUS'
+        }
+      ];
+      stormMasterComponents.forEach(function(masterComponent) {
+        this.setHostsToConfig(stormService, masterComponent.configName, masterComponent.componentName);
+      }, this);
+    }
     this.setHostsToConfig(hbaseService, 'hbasemaster_host', 'HBASE_MASTER');
     this.setHostsToConfig(zooKeeperService, 'zookeeperserver_hosts', 'ZOOKEEPER_SERVER');
   },

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

@@ -45,12 +45,14 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     var hosts = App.Host.find();
     var result = [];
     var componentsToDisplay = ['NAMENODE', 'SECONDARY_NAMENODE', 'DATANODE', 'JOBTRACKER', 'ZOOKEEPER_SERVER', 'HIVE_SERVER', 'TASKTRACKER',
-      'OOZIE_SERVER', 'NAGIOS_SERVER', 'HBASE_MASTER', 'HBASE_REGIONSERVER','HISTORYSERVER','RESOURCEMANAGER','NODEMANAGER','JOURNALNODE'];
+      'OOZIE_SERVER', 'NAGIOS_SERVER', 'HBASE_MASTER', 'HBASE_REGIONSERVER','HISTORYSERVER','RESOURCEMANAGER','NODEMANAGER','JOURNALNODE',
+      'SUPERVISOR', 'NIMBUS', 'STORM_UI_SERVER'];
     var securityUsers = [];
     if (!securityUsers || securityUsers.length < 1) { // Page could be refreshed in middle
       securityUsers = this.getSecurityUsers();
     }
     var isHbaseInstalled = App.Service.find().findProperty('serviceName', 'HBASE');
+    var isStormInstalled = App.Service.find().findProperty('serviceName', 'STORM');
     var generalConfigs = configs.filterProperty('serviceName', 'GENERAL');
     var hdfsConfigs = configs.filterProperty('serviceName', 'HDFS');
     var realm = generalConfigs.findProperty('name', 'kerberos_domain').value;
@@ -64,13 +66,18 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
     var oozieUserId = securityUsers.findProperty('name', 'oozie_user').value;
     var nagiosUserId = securityUsers.findProperty('name', 'nagios_user').value;
     var hadoopGroupId = securityUsers.findProperty('name', 'user_group').value;
+    var stormUserId = securityUsers.findProperty('name', 'storm_user').value;
 
     var smokeUser = smokeUserId + '@' + realm;
     var hdfsUser = hdfsUserId + '@' + realm;
     var hbaseUser = hbaseUserId + '@' + realm;
+    var stormUser = stormUserId + '@' + realm;
+
     var smokeUserKeytabPath = generalConfigs.findProperty('name', 'smokeuser_keytab').value;
     var hdfsUserKeytabPath = generalConfigs.findProperty('name', 'hdfs_user_keytab').value;
     var hbaseUserKeytabPath = generalConfigs.findProperty('name', 'hbase_user_keytab').value;
+    var stormUserKeytabPath = generalConfigs.findProperty('name', 'storm_keytab').value;
+
     var hadoopHttpPrincipal = hdfsConfigs.findProperty('name', 'hadoop_http_principal_name');
     var hadoopHttpKeytabPath = hdfsConfigs.findProperty('name', 'hadoop_http_keytab').value;
     var componentToOwnerMap = {
@@ -88,7 +95,10 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
       'OOZIE_SERVER': oozieUserId,
       'NAGIOS_SERVER': nagiosUserId,
       'HBASE_MASTER': hbaseUserId,
-      'HBASE_REGIONSERVER': hbaseUserId
+      'HBASE_REGIONSERVER': hbaseUserId,
+      'SUPERVISOR': stormUserId,
+      'NIMBUS': stormUserId,
+      'STORM_UI_SERVER': stormUserId
     };
 
     var addedPrincipalsHost = {}; //Keys = host_principal, Value = 'true'
@@ -126,6 +136,18 @@ App.MainAdminSecurityAddStep3Controller = Em.Controller.extend({
           acl: '440'
         });
       }
+      if (isStormInstalled) {
+        result.push({
+          host: host.get('hostName'),
+          component: Em.I18n.t('admin.addSecurity.user.stormUser'),
+          principal: stormUser,
+          keytabFile: stringUtils.getFileFromPath(stormUserKeytabPath),
+          keytab: stringUtils.getPath(stormUserKeytabPath),
+          owner: stormUserId,
+          group: hadoopGroupId,
+          acl: '440'
+        });
+      }
 
       this.setComponentConfig(result,host,'NAMENODE','HDFS','hadoop_http_principal_name','hadoop_http_keytab',Em.I18n.t('admin.addSecurity.hdfs.user.httpUser'),hadoopGroupId);
       this.setComponentConfig(result,host,'SECONDARY_NAMENODE','HDFS','hadoop_http_principal_name','hadoop_http_keytab',Em.I18n.t('admin.addSecurity.hdfs.user.httpUser'),hadoopGroupId);

+ 9 - 4
ambari-web/app/controllers/main/admin/security/add/step4.js

@@ -22,7 +22,7 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   name: 'mainAdminSecurityAddStep4Controller',
 
   serviceUsersBinding: 'App.router.mainAdminSecurityController.serviceUsers',
-  totalSteps: 4,
+  totalSteps: 3,
 
   secureServices: function() {
     return  this.get('content.services');
@@ -65,12 +65,17 @@ App.MainAdminSecurityAddStep4Controller = App.MainAdminSecurityProgressControlle
   },
 
   loadStages: function () {
-    this.get('stages').pushObjects([
+    var stages = [
       App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES', isVisible: true}),
       App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS', isVisible: true}),
-      App.Poll.create({stage: 'stage5', label: Em.I18n.translations['admin.addSecurity.apply.delete.ats'], isPolling: false, name: 'DELETE_ATS', isVisible: false}),
       App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES', isVisible: true})
-    ]);
+    ];
+    // no need to remove ATS component if YARN and ATS are not installed
+    if (this.get('secureServices').findProperty('serviceName', 'YARN') && !App.get('stackDependedComponents').findProperty('componentName', 'APP_TIMELINE_SERVER')) {
+      stages.splice(2, 0, App.Poll.create({stage: 'stage5', label: Em.I18n.translations['admin.addSecurity.apply.delete.ats'], isPolling: false, name: 'DELETE_ATS', isVisible: false}));
+      this.set('totalSteps', 4);
+    }
+    this.get('stages').pushObjects(stages);
   },
 
   loadStep: function () {

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

@@ -309,11 +309,20 @@ App.MainAdminSecurityProgressController = Em.Controller.extend({
     serviceConfigTags.forEach(function (_serviceConfigTags) {
       var configs = _serviceConfigTags.configs;
       for (var key in configs) {
-        configs[key] = App.config.escapeXMLCharacters(configs[key]);
+        configs[key] = this.setServerConfigValue(key, configs[key]);
       }
     }, this);
   },
 
+  setServerConfigValue: function(configName, value) {
+    switch (configName) {
+      case 'storm.zookeeper.servers':
+        return value;
+      default:
+        return App.config.escapeXMLCharacters(value);
+    }
+  },
+
   saveStagesOnRequestId: function () {
     this.saveStages();
   }.observes('stages.@each.requestId'),

+ 13 - 0
ambari-web/app/data/HDP2/secure_configs.js

@@ -126,6 +126,19 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'Nagios Server', displayName:  'Nagios Server'})
     ],
     configs: configProperties.filterProperty('serviceName', 'NAGIOS')
+  },
+  {
+    serviceName: 'STORM',
+    displayName: 'Storm',
+    filename: 'storm-site',
+    configCategories: [
+      App.ServiceConfigCategory.create({ name: 'NIMBUS', displayName:  'Nimbus'}),
+      App.ServiceConfigCategory.create({ name: 'STORM_UI_SERVER', displayName:  'Storm UI Server'}),
+      App.ServiceConfigCategory.create({ name: 'SUPERVISOR', displayName:  'Supervisor'})
+    ],
+    sites: ['storm-site'],
+    configs: configProperties.filterProperty('serviceName', 'STORM')
   }
 
+
 ];

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

@@ -920,6 +920,160 @@ module.exports =
       "serviceName": "NAGIOS",
       "category": "Nagios Server",
       "component": "NAGIOS_SERVER"
+    },
+  /**********************************************STORM***************************************/
+    {
+      "id": "puppet var",
+      "name": "supervisor_hosts",
+      "displayName": "Supervisor hosts",
+      "value": "",
+      "defaultValue": "",
+      "description": "The host that the master server is running on.",
+      "displayType": "slaveHosts",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "SUPERVISOR"
+    },
+    {
+      "id": "puppet var",
+      "name": "storm_ui_server_host",
+      "displayName": "Storm UI Server host",
+      "value": "",
+      "defaultValue": "",
+      "description": "Storm UI Server host",
+      "displayType": "masterHost",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "STORM_UI_SERVER"
+    },
+    {
+      "id": "puppet var",
+      "name": "nimbus_host",
+      "displayName": "Nimbus host",
+      "value": "",
+      "defaultValue": "",
+      "description": "Nimbus host",
+      "displayType": "masterHost",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "NIMBUS"
+    },
+    {
+      "id": "puppet var",
+      "name": "supervisor_keytab",
+      "displayName": "Path to Supervisor keytab file",
+      "value": "",
+      "defaultValue": "/etc/security/keytabs/storm.service.keytab",
+      "description": "Path to the Storm Service keytab file",
+      "displayType": "directory",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "SUPERVISOR",
+      "component": "SUPERVISOR"
+    },
+    {
+      "id": "puppet var",
+      "name": "supervisor_principal_name",
+      "displayName": "Supervisor principal name",
+      "value": "",
+      "defaultValue": "storm/_HOST",
+      "description": "Principal name for Supervisor. _HOST will get automatically replaced with actual hostname at an instance of Supervisor.",
+      "displayType": "principal",
+      "isVisible": true,
+      "isOverridable": false,
+      "isConfigurable": false,
+      "serviceName": "STORM",
+      "category": "SUPERVISOR",
+      "component": "SUPERVISOR"
+    },
+    {
+      "id": "puppet var",
+      "name": "nimbus_keytab",
+      "displayName": "Path to Nimbus keytab file",
+      "value": "",
+      "defaultValue": "/etc/security/keytabs/storm.service.keytab",
+      "description": "Path to the Nimbus keytab file",
+      "displayType": "directory",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "NIMBUS",
+      "component": "NIMBUS"
+    },
+    {
+      "id": "puppet var",
+      "name": "nimbus_principal_name",
+      "displayName": "Nimbus principal name",
+      "value": "",
+      "defaultValue": "storm/_HOST",
+      "description": "Principal name for Nimbus. _HOST will get automatically replaced with actual hostname at an instance of Nimbus.",
+      "displayType": "principal",
+      "isVisible": true,
+      "isOverridable": false,
+      "isConfigurable": false,
+      "serviceName": "STORM",
+      "category": "NIMBUS",
+      "component": "NIMBUS"
+    },
+    {
+      "id": "puppet var",
+      "name": "storm_ui_server_keytab",
+      "displayName": "Path to Storm UI Server keytab file",
+      "value": "",
+      "defaultValue": "/etc/security/keytabs/storm.service.keytab",
+      "description": "Path to the Storm UI Server keytab file",
+      "displayType": "directory",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "STORM",
+      "category": "STORM_UI_SERVER",
+      "component": "STORM_UI_SERVER"
+    },
+    {
+      "id": "puppet var",
+      "name": "storm_ui_server_principal_name",
+      "displayName": "Storm UI Server principal name",
+      "value": "",
+      "defaultValue": "storm/_HOST",
+      "description": "Principal name for Storm UI Server. _HOST will get automatically replaced with actual hostname at an instance of Storm UI Server.",
+      "displayType": "principal",
+      "isVisible": true,
+      "isOverridable": false,
+      "isConfigurable": false,
+      "serviceName": "STORM",
+      "category": "STORM_UI_SERVER",
+      "component": "STORM_UI_SERVER"
+    },
+    {
+      "id": "puppet var",
+      "name": "storm_principal_name",
+      "displayName": "Storm principal name",
+      "value": "",
+      "defaultValue": "storm",
+      "description": "This is the principal name for Storm user",
+      "displayType": "principal",
+      "isVisible": true,
+      "isOverridable": false,
+      "isConfigurable": false,
+      "serviceName": "GENERAL",
+      "category": "AMBARI"
+    },
+    {
+      "id": "puppet var",
+      "name": "storm_keytab",
+      "displayName": "Path to Storm keytab file",
+      "value": "",
+      "defaultValue": "/etc/security/keytabs/storm.service.keytab",
+      "description": "Path to the Storm Service keytab file",
+      "displayType": "directory",
+      "isVisible": true,
+      "isOverridable": false,
+      "serviceName": "GENERAL",
+      "category": "AMBARI"
     }
   ]
 };

+ 1 - 0
ambari-web/app/messages.js

@@ -941,6 +941,7 @@ Em.I18n.translations = {
   'admin.addSecurity.user.smokeUser': 'Ambari Smoke Test User',
   'admin.addSecurity.user.hdfsUser': 'HDFS User',
   'admin.addSecurity.user.hbaseUser': 'HBase User',
+  'admin.addSecurity.user.stormUser': 'Storm User',
   'admin.addSecurity.hdfs.user.httpUser': 'HDFS SPNEGO User',
   'admin.addSecurity.rm.user.httpUser': 'ResourceManager SPNEGO User',
   'admin.addSecurity.nm.user.httpUser': 'NodeManager SPNEGO User',

+ 64 - 1
ambari-web/test/controllers/main/admin/security/add/step4_test.js

@@ -42,7 +42,7 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
 
     controller.set('stages', [
       App.Poll.create({stage: 'stage2', isStarted: false, isPolling: true, isCompleted: false, start: function(){}}),
-      App.Poll.create({stage: 'stage3', isStarted: false, isPolling: false, isCompleted: false, start: function(){}}),
+      App.Poll.create({stage: 'stage3', isStarted: false, isPolling: false, isCompleted: false, name: 'APPLY_CONFIGURATIONS', start: function(){}}),
       App.Poll.create({stage: 'stage4', isStarted: false, isPolling: true, isCompleted: false, start: function(){}})
     ]);
 
@@ -61,4 +61,67 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
       expect(controller.get('stages').findProperty('stage', 'stage4').get('isStarted')).to.equal(true);
     });
   });
+
+  describe('#loadStages()', function() {
+    describe('YARN installed with ATS', function() {
+      beforeEach(function(){
+        controller.reopen({
+          secureServices: function() {
+            return [
+              Em.Object.create({
+                serviceName: 'YARN'
+              })
+            ];
+          }.property()
+        });
+        App.set('stackDependedComponents', []);
+        controller.set('stages', []);
+        controller.set('totalSteps', 3);
+        controller.loadStages();
+      });
+
+      it('delete ATS component stage should be after stage3', function() {
+        expect(controller.get('stages').indexOf(controller.get('stages').findProperty('stage','stage5'))).to.eql(2);
+      });
+
+      it('stages length should be equal to 4', function() {
+        expect(controller.get('stages').length).to.eql(4);
+      });
+
+      it('total steps should be equal to 4', function() {
+        expect(controller.get('totalSteps')).to.eql(4);
+      });
+    });
+
+    describe('YARN installed without ATS', function() {
+      beforeEach(function(){
+        controller.reopen({
+          secureServices: function() {
+            return [
+              Em.Object.create({
+                serviceName: 'YARN'
+              })
+            ];
+          }.property()
+        });
+        App.set('stackDependedComponents', [
+          Em.Object.create({
+            componentName: 'APP_TIMELINE_SERVER'
+          })
+        ]);
+        controller.set('stages', []);
+        controller.set('totalSteps', 3);
+        controller.loadStages();
+      });
+
+      it('stages length should be equal to 3', function() {
+        expect(controller.get('stages').length).to.eql(3);
+      });
+
+      it('total steps should be equal to 3', function() {
+        expect(controller.get('totalSteps')).to.eql(3);
+      });
+    });
+
+  });
 });