incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject svn commit: r1497647 - in /incubator/ambari/trunk/ambari-web/app: controllers/main/admin/security.js controllers/main/admin/security/add/step2.js messages.js templates/main/admin/security/add/step2.hbs
Date Fri, 28 Jun 2013 05:11:28 GMT
Author: srimanth
Date: Fri Jun 28 05:11:28 2013
New Revision: 1497647

URL: http://svn.apache.org/r1497647
Log:
AMBARI-2519. Add download CSV action for security wizard. (srimanth)

Modified:
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js
    incubator/ambari/trunk/ambari-web/app/messages.js
    incubator/ambari/trunk/ambari-web/app/templates/main/admin/security/add/step2.hbs

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js?rev=1497647&r1=1497646&r2=1497647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security.js Fri Jun 28 05:11:28
2013
@@ -141,6 +141,11 @@ App.MainAdminSecurityController = Em.Con
       name: 'proxyuser_group',
       value: configs['proxyuser_group'] ? configs['proxyuser_group'] : 'users'
     });
+    serviceUsers.pushObject({
+      id: 'puppet var',
+      name: 'smokeuser',
+      value: configs['smokeuser'] ? configs['smokeuser'] : 'ambari-qa'
+    });
   },
 
   showSecurityErrorPopup: function () {

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js?rev=1497647&r1=1497646&r2=1497647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js Fri
Jun 28 05:11:28 2013
@@ -257,6 +257,108 @@ App.MainAdminSecurityAddStep2Controller 
     if (!this.get('isSubmitDisabled')) {
       this.showHostPrincipalKeytabList();
     }
-  }
-
+  },
+  
+    doDownloadCsv: function(){
+      var blob = new Blob([this.buildCvsContent()], {type: "text/csv;charset=utf-8"});
+      saveAs(blob, "host-principal-keytab-list.csv");
+    },
+    
+    buildCvsContent: function() {
+      var configs = this.get('stepConfigs');
+      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'];
+      var securityUsers = App.router.get('mainAdminSecurityController').get('serviceUsers');
+      if (!securityUsers || securityUsers.length < 1) { // Page could be refreshed in
middle
+        if (App.testMode) {
+          securityUsers.pushObject({id: 'puppet var', name: 'hdfs_user', value: 'hdfs'});
+          securityUsers.pushObject({id: 'puppet var', name: 'mapred_user', value: 'mapred'});
+          securityUsers.pushObject({id: 'puppet var', name: 'hbase_user', value: 'hbase'});
+          securityUsers.pushObject({id: 'puppet var', name: 'hive_user', value: 'hive'});
+          securityUsers.pushObject({id: 'puppet var', name: 'smokeuser', value: 'ambari-qa'});
+        } else {
+          App.router.get('mainAdminSecurityController').setSecurityStatus();
+          securityUsers = App.router.get('mainAdminSecurityController').get('serviceUsers');
+        }
+      }
+      var generalConfigs = configs.findProperty('serviceName', 'GENERAL').configs;
+      var realm = generalConfigs.findProperty('name', 'kerberos_domain').get('value');
+      var smokeUser = securityUsers.findProperty('name', 'smokeuser').value + '@' + realm;
+      var hdfsUser = securityUsers.findProperty('name', 'hdfs_user').value + '@' + realm;
+      var hbaseUser = securityUsers.findProperty('name', 'hbase_user').value + '@' + realm;
+      var smokeUserKeytabPath = generalConfigs.findProperty('name', 'smokeuser_keytab').get('value');
+      var hdfsUserKeytabPath = generalConfigs.findProperty('name', 'keytab_path').get('value')
+ "/hdfs.headless.keytab";
+      var hbaseUserKeytabPath = generalConfigs.findProperty('name', 'keytab_path').get('value')
+ "/hbase.headless.keytab";
+      var httpPrincipal = generalConfigs.findProperty('name', 'hadoop_http_principal_name');
+      var httpKeytabPath = generalConfigs.findProperty('name', 'hadoop_http_keytab').get('value');
+      var addedPrincipalsHost = {}; //Keys = host_principal, Value = 'true'
+      
+      hosts.forEach(function(host){
+        result.push({
+          host: host.get('hostName'),
+          component: Em.I18n.t('admin.addSecurity.user.smokeUser'),
+          principal: smokeUser,
+          keytab: smokeUserKeytabPath
+        });
+        result.push({
+          host: host.get('hostName'),
+          component: Em.I18n.t('admin.addSecurity.user.hdfsUser'),
+          principal: hdfsUser,
+          keytab: hdfsUserKeytabPath
+        });
+        result.push({
+          host: host.get('hostName'),
+          component: Em.I18n.t('admin.addSecurity.user.hbaseUser'),
+          principal: hbaseUser,
+          keytab: hbaseUserKeytabPath
+        });
+        if(host.get('hostComponents').someProperty('componentName', 'NAMENODE') || 
+          host.get('hostComponents').someProperty('componentName', 'SECONDARY_NAMENODE')
||
+          host.get('hostComponents').someProperty('componentName', 'WEBHCAT_SERVER') ||
+          host.get('hostComponents').someProperty('componentName', 'OOZIE_SERVER')){
+          result.push({
+            host: host.get('hostName'),
+            component: Em.I18n.t('admin.addSecurity.user.httpUser'),
+            principal: httpPrincipal.get('value').replace('_HOST', host.get('hostName'))
+ httpPrincipal.get('unit'),
+            keytab: httpKeytabPath
+          });
+        }
+        host.get('hostComponents').forEach(function(hostComponent){
+          if(componentsToDisplay.contains(hostComponent.get('componentName'))){
+            var serviceConfigs = configs.findProperty('serviceName', hostComponent.get('service.serviceName')).get('configs');
+            var principal, keytab;
+            serviceConfigs.forEach(function(config){
+              if (config.get('component') && config.get('component') === hostComponent.get('componentName'))
{
+                if (config.get('name').endsWith('_principal_name')) {
+                  principal = config.get('value').replace('_HOST', host.get('hostName'))
+ config.get('unit');
+                } else if (config.get('name').endsWith('_keytab') || config.get('name').endsWith('_keytab_path'))
{
+                  keytab = config.get('value');
+                }
+              } else if (config.get('components') && config.get('components').contains(hostComponent.get('componentName')))
{
+                if (config.get('name').endsWith('_principal_name')) {
+                  principal = config.get('value').replace('_HOST', host.get('hostName'))
+ config.get('unit');
+                } else if (config.get('name').endsWith('_keytab') || config.get('name').endsWith('_keytab_path'))
{
+                  keytab = config.get('value');
+                }
+              }
+            });
+            
+   
+            var key = host.get('hostName') + "--" + principal;
+            if (!addedPrincipalsHost[key]) {
+              result.push({
+                host: host.get('hostName'),
+                component: hostComponent.get('displayName'),
+                principal: principal,
+                keytab: keytab
+              });
+              addedPrincipalsHost[key] = true;
+            }
+          }
+        });
+      });
+      return stringUtils.arrayToCSV(result);
+    }
 });
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-web/app/messages.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/messages.js?rev=1497647&r1=1497646&r2=1497647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/messages.js (original)
+++ incubator/ambari/trunk/ambari-web/app/messages.js Fri Jun 28 05:11:28 2013
@@ -621,6 +621,10 @@ Em.I18n.translations = {
   'admin.addSecurity.apply.stage3': '2. Save Configurations',
   'admin.addSecurity.apply.stage4': '3. Start Services',
   'admin.addSecurity.apply.stage5': '5. Smoke Test',
+  'admin.addSecurity.user.smokeUser': 'Ambari Smoke Test User',
+  'admin.addSecurity.user.hdfsUser': 'Ambari HDFS Test User',
+  'admin.addSecurity.user.hbaseUser': 'Ambari HBase Test User',
+  'admin.addSecurity.user.httpUser': 'SPNEGO User',
   'admin.addSecurity.enable.onClose': 'You are in the process of enabling security on your
cluster. ' +
     'Are you sure you want to quit? If you quit, ' +
     'you may have to re-run the security wizard from the beginning to enable security.',

Modified: incubator/ambari/trunk/ambari-web/app/templates/main/admin/security/add/step2.hbs
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/templates/main/admin/security/add/step2.hbs?rev=1497647&r1=1497646&r2=1497647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/templates/main/admin/security/add/step2.hbs (original)
+++ incubator/ambari/trunk/ambari-web/app/templates/main/admin/security/add/step2.hbs Fri
Jun 28 05:11:28 2013
@@ -29,5 +29,6 @@
 
     <a class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}}
       {{action submit target="controller"}}>{{t common.apply}} &rarr;</a>
+    <a style="margin-right:5px;" class="btn btn-info pull-right" {{action doDownloadCsv
target="controller"}}>{{t admin.security.step2.popup.downloadCSV}}</a>
   </div>
 </div>
\ No newline at end of file



Mime
View raw message