ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: AMBARI-9137. Configure Identities page tweaks. (jaimin)
Date Thu, 15 Jan 2015 02:06:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 65577e223 -> d32eefdaf


AMBARI-9137. Configure Identities page tweaks. (jaimin)


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

Branch: refs/heads/trunk
Commit: d32eefdafd14c30b852128b38245581223fb97ed
Parents: 65577e2
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Wed Jan 14 18:05:34 2015 -0800
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Wed Jan 14 18:05:41 2015 -0800

----------------------------------------------------------------------
 .../app/controllers/main/admin/kerberos.js      | 27 ++++++-
 .../main/admin/kerberos/step4_controller.js     | 83 +++++++++++++++-----
 ambari-web/app/data/HDP2/site_properties.js     | 37 +++++++++
 ambari-web/app/messages.js                      |  4 +-
 .../app/mixins/wizard/addSecurityConfigs.js     | 12 ++-
 .../admin/kerberos/step4_controller_test.js     | 34 ++++----
 6 files changed, 152 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/app/controllers/main/admin/kerberos.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos.js b/ambari-web/app/controllers/main/admin/kerberos.js
index be5b23f..640c92c 100644
--- a/ambari-web/app/controllers/main/admin/kerberos.js
+++ b/ambari-web/app/controllers/main/admin/kerberos.js
@@ -153,13 +153,34 @@ App.MainAdminKerberosController = App.KerberosWizardStep4Controller.extend({
    */
   prepareConfigProperties: function(configs) {
     var configProperties = configs.slice(0);
+    var siteProperties = App.config.get('preDefinedSiteProperties');
     var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
     configProperties = configProperties.filter(function(item) {
       return installedServiceNames.contains(item.get('serviceName'));
     });
-    configProperties.forEach(function(item) {
-      if (item.get('serviceName') == 'Cluster') item.set('category', 'General');
-      else item.set('category', 'Advanced');
+    configProperties.setEach('isSecureConfig', false);
+    configProperties.forEach(function(property, item, allConfigs) {
+      if (property.get('observesValueFrom')) {
+        var observedValue = allConfigs.findProperty('name', property.get('observesValueFrom')).get('value');
+        property.set('value', observedValue);
+        property.set('defaultValue', observedValue);
+      }
+      if (property.get('serviceName') == 'Cluster') {
+        property.set('category', 'Global');
+      } else {
+        property.set('category', property.get('serviceName'));
+      }
+      // All user identity should be grouped under "Ambari Principals" category
+      if (property.get('identityType') == 'user') property.set('category', 'Ambari Principals');
+      var siteProperty = siteProperties.findProperty('name', property.get('name'));
+      if (siteProperty) {
+        if (siteProperty.category === property.get('category')) {
+          property.set('displayName',siteProperty.displayName);
+          if (siteProperty.index) {
+            property.set('index', siteProperty.index);
+          }
+        }
+      }
     });
     configProperties.setEach('isEditable', false);
     return configProperties;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
index 8ac005c..79707dd 100644
--- a/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
+++ b/ambari-web/app/controllers/main/admin/kerberos/step4_controller.js
@@ -22,7 +22,7 @@ require('controllers/wizard/step7_controller');
 App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecurityConfigs,
{
   name: 'kerberosWizardStep4Controller',
 
-  adminPropertyNames: ['admin_principal', 'admin_password'],
+  adminPropertyNames: [{name: 'admin_principal', displayName: 'Admin principal'}, {name:
'admin_password', displayName: 'Admin password'}],
   
   clearStep: function() {
     this.set('isRecommendedLoaded', false);
@@ -42,20 +42,45 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
   /**
    * Create service config object for Kerberos service.
    *
-   * @param {Em.Object[]} configCategories
    * @param {App.ServiceConfigProperty[]} configs
    * @returns {Em.Object} 
    */
-  createServiceConfig: function(configCategories, configs) {
-    return App.ServiceConfig.create({
-      displayName: 'Kerberos Descriptor',
-      name: 'KERBEROS',
-      serviceName: 'KERBEROS',
-      configCategories: configCategories,
-      configs: configs,
+  createServiceConfig: function(configs) {
+    // Identity configs related to user principal
+    var userConfigs = configs.filterProperty('identityType','user');
+    var nonUserConfig = configs.rejectProperty('identityType','user');
+    var categoryForUserConfigs = [
+      App.ServiceConfigCategory.create({ name: 'Ambari Principals', displayName: 'Ambari
Principals'})
+    ];
+    var categoryForNonUserConfigs =  [
+      App.ServiceConfigCategory.create({ name: 'Global', displayName: 'Global'})
+    ].concat(this.createCategoryForServices());
+    return [
+      App.ServiceConfig.create({
+      displayName: 'General',
+      name: 'GENERAL',
+      serviceName: 'KERBEROS_GENERAL',
+      configCategories: categoryForUserConfigs,
+      configs: userConfigs,
       showConfig: true,
       selected: true
-    });
+    }),
+      App.ServiceConfig.create({
+        displayName: 'Advanced',
+        name: 'ADVANCED',
+        serviceName: 'KERBEROS_ADVANCED',
+        configCategories: categoryForNonUserConfigs,
+        configs: nonUserConfig,
+        showConfig: true,
+        selected: false
+      })
+    ];
+  },
+
+  createCategoryForServices: function() {
+    return App.Service.find().mapProperty('serviceName').map(function(item) {
+      return App.ServiceConfigCategory.create({ name: item, displayName: App.Service.find().findProperty('serviceName',item).get('displayName')});
+    })
   },
 
   /**
@@ -64,19 +89,17 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
    * @param {App.ServiceConfigProperty[]} configs
    */
   setStepConfigs: function(configs) {
-    var selectedService = App.StackService.find().findProperty('serviceName', 'KERBEROS');
-    var configCategories = selectedService.get('configCategories');
     var configProperties = this.prepareConfigProperties(configs);
     if (this.get('wizardController.name') == 'addServiceController') {
       // config properties for installed services should be disabled on Add Service Wizard
       configProperties.forEach(function(item) {
-        if (this.get('adminPropertyNames').contains(item.get('name'))) return;
+        if (this.get('adminPropertyNames').mapProperty('name').contains(item.get('name')))
return;
         if (this.get('installedServiceNames').contains(item.get('serviceName')) || item.get('serviceName')
== 'Cluster') {
           item.set('isEditable', false);
         }
       }, this);
     }
-    this.get('stepConfigs').pushObject(this.createServiceConfig(configCategories, configProperties));
+    this.get('stepConfigs').pushObjects(this.createServiceConfig(configProperties));
     this.set('selectedService', this.get('stepConfigs')[0]);
   },
 
@@ -97,12 +120,13 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
     var installedServiceNames = ['Cluster'].concat(App.Service.find().mapProperty('serviceName'));
     var adminProps = [];
     var configProperties = configs.slice(0);
+    var siteProperties = App.config.get('preDefinedSiteProperties');
     if (this.get('wizardController.name') == 'addServiceController') {
       installedServiceNames = installedServiceNames.concat(this.get('selectedServiceNames'));
       this.get('adminPropertyNames').forEach(function(item) {
-        var property = storedServiceConfigs.filterProperty('filename', 'krb5-conf.xml').findProperty('name',
item);
+        var property = storedServiceConfigs.filterProperty('filename', 'krb5-conf.xml').findProperty('name',
item.name);
         if (!!property) {
-          var _prop = App.ServiceConfigProperty.create($.extend({}, property, { value: '',
defaultValue: '', serviceName: 'Cluster', displayName: item }));
+          var _prop = App.ServiceConfigProperty.create($.extend({}, property, { name: item.name,
value: '', defaultValue: '', serviceName: 'Cluster', displayName: item.displayName}));
           _prop.validate();
           adminProps.push(_prop);
         }
@@ -125,8 +149,23 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
         property.set('value', observedValue);
         property.set('defaultValue', observedValue);
       }
-      if (property.get('serviceName') == 'Cluster') property.set('category', 'General');
-      else property.set('category', 'Advanced');
+      if (property.get('serviceName') == 'Cluster') {
+        property.set('category', 'Global');
+      }
+      else {
+        property.set('category', property.get('serviceName'));
+      }
+      // All user identity should be grouped under "Ambari Principals" category
+      if (property.get('identityType') == 'user') property.set('category', 'Ambari Principals');
+      var siteProperty = siteProperties.findProperty('name', property.get('name'));
+      if (siteProperty) {
+        if (siteProperty.category === property.get('category')) {
+          property.set('displayName',siteProperty.displayName);
+          if (siteProperty.index) {
+            property.set('index', siteProperty.index);
+          }
+        }
+      }
     });
 
     return configProperties;
@@ -139,7 +178,8 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
    */
   spnegoPropertiesObserver: function(configProperty) {
     var self = this;
-    this.get('stepConfigs')[0].get('configs').forEach(function(config) {
+    var stepConfig =  this.get('stepConfigs').findProperty('name', 'ADVANCED');
+    stepConfig.get('configs').forEach(function(config) {
       if (config.get('observesValueFrom') == configProperty.get('name')) {
         Em.run.once(self, function() {
           config.set('value', configProperty.get('value'));
@@ -156,7 +196,10 @@ App.KerberosWizardStep4Controller = App.WizardStep7Controller.extend(App.AddSecu
   
   saveConfigurations: function() {
     var kerberosDescriptor = this.get('kerberosDescriptor');
-    var configs = this.get('stepConfigs')[0].get('configs');
+    var configs = [];
+    this.get('stepConfigs').forEach(function(_stepConfig){
+      configs = configs.concat(_stepConfig.get('configs'));
+    });
     this.updateKerberosDescriptor(kerberosDescriptor, configs);
     this.get('wizardController').saveKerberosDescriptorConfigs(kerberosDescriptor);
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index 6ab8adb..fa1490a 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -4502,6 +4502,43 @@ module.exports =
       "filename": "ams-site.xml",
       "category": "MetricCollector",
       "index" : 3
+    },
+  /************************************************Kerberos Descriptor******************************************/
+    {
+      "name": "smokeuser_principal_name",
+      "displayName": "Smokeuser principal",
+      "category": "Ambari Principals",
+      "index" : 1
+    },
+    {
+      "name": "smokeuser_keytab",
+      "displayName": "Smokeuser keytab",
+      "category": "Ambari Principals",
+      "index" : 2
+    },
+    {
+      "name": "hdfs_principal_name",
+      "displayName": "HDFS user principal",
+      "category": "Ambari Principals",
+      "index" : 3
+    },
+    {
+      "name": "hdfs_user_keytab",
+      "displayName": "HDFS user keytab",
+      "category": "Ambari Principals",
+      "index" : 4
+    },
+    {
+      "name": "hbase_principal_name",
+      "displayName": "HBase user principal",
+      "category": "Ambari Principals",
+      "index" : 5
+    },
+    {
+      "name": "hbase_user_keytab",
+      "displayName": "HBase user keytab",
+      "category": "Ambari Principals",
+      "index" : 6
     }
   ]
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 5fe6c4f..a9ea7e3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -983,10 +983,10 @@ Em.I18n.translations = {
   'admin.kerberos.wizard.step1.body.text': 'What type of KDC do you plan on using?',
   'admin.kerberos.wizard.step1.option.kdc': 'Existing MIT KDC',
   'admin.kerberos.wizard.step1.option.kdc.condition.1': 'An administrative principal is created
in the MIT KDC to be shared with Ambari when prompted.',
-  'admin.kerberos.wizard.step1.option.kdc.condition.2': 'Java Cryptography Extension (JCE)
is installed on all hosts.',
+  'admin.kerberos.wizard.step1.option.kdc.condition.2': 'Java Cryptography Extension (JCE)
is installed on ambari server host.',
   'admin.kerberos.wizard.step1.option.ad': 'Existing Active Directory',
   'admin.kerberos.wizard.step1.option.ad.condition.1': 'An administrative principal is created
in the Active Directory to be shared with Ambari when prompted.',
-  'admin.kerberos.wizard.step1.option.ad.condition.2': 'Java Cryptography Extension (JCE)
is installed on all hosts.',
+  'admin.kerberos.wizard.step1.option.ad.condition.2': 'Java Cryptography Extension (JCE)
is installed on ambari server host.',
   'admin.kerberos.wizard.step1.prerequisites.label': 'Following prerequisites needs to be
checked to progress ahead in the wizard.',
   'admin.kerberos.wizard.step2.info.body': 'Please configure kerberos related properties.',
   'admin.kerberos.wizard.step3.task0.title': 'Install Kerberos',

http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/app/mixins/wizard/addSecurityConfigs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/wizard/addSecurityConfigs.js b/ambari-web/app/mixins/wizard/addSecurityConfigs.js
index ee14a49..2c63120 100644
--- a/ambari-web/app/mixins/wizard/addSecurityConfigs.js
+++ b/ambari-web/app/mixins/wizard/addSecurityConfigs.js
@@ -407,9 +407,15 @@ App.AddSecurityConfigs = Em.Mixin.create({
     // generate configs for root level identities object, currently spnego property
     clusterConfigs = clusterConfigs.concat(this.createConfigsByIdentities(kerberosDescriptor.identities,
'Cluster'));
     clusterConfigs.setEach('serviceName', 'Cluster');
-    // generate properties for services object
     kerberosDescriptor.services.forEach(function (service) {
       var serviceName = service.name;
+      // generate configs for service level identity objects
+      if (service.identities) {
+        var serviceIdentityConfigs = self.createConfigsByIdentities(service.identities, serviceName);
+        serviceIdentityConfigs.setEach('serviceName', serviceName);
+        configs = configs.concat(serviceIdentityConfigs);
+      }
+      // generate configs for service component level identity  object
       service.components.forEach(function (component) {
         var componentName = component.name;
         if (component.identities) {
@@ -446,9 +452,9 @@ App.AddSecurityConfigs = Em.Mixin.create({
         isVisible: true,
         isSecureConfig: true,
         componentName: componentName,
-        name: identity.name
+        name: identity.name,
+        identityType: identity.principal && identity.principal.type
       };
-
       self.parseIdentityObject(identity).forEach(function (item) {
         configs.push(App.ServiceConfigProperty.create($.extend({}, defaultObject, item)));
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/d32eefda/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
index 361175b..12aec8b 100644
--- a/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/kerberos/step4_controller_test.js
@@ -22,13 +22,10 @@ describe('App.KerberosWizardStep4Controller', function() {
   
   describe('#isSubmitDisabled', function() {
     var controller = App.KerberosWizardStep4Controller.create({});
-    var configCategories = Em.A([
-      App.ServiceConfigCategory.create({ name: 'Advanced', displayName: 'Advanced'})
-    ]);
     var configs = Em.A([
-      App.ServiceConfigProperty.create({ name: 'prop1', value: 'someVal1', category: 'Advanced'})
+      App.ServiceConfigProperty.create({ name: 'prop1', value: 'someVal1', identityType:
'user', category: 'Ambari Principals'})
     ]);
-    controller.set('stepConfigs', [controller.createServiceConfig(configCategories, configs)]);
+    controller.set('stepConfigs', controller.createServiceConfig(configs));
     
     it('configuration errors are absent, submit should be not disabled', function() {
       expect(controller.get('stepConfigs')[0].get('errorCount')).to.be.eql(0);
@@ -46,7 +43,9 @@ describe('App.KerberosWizardStep4Controller', function() {
   describe('#createServiceConfig', function() {
     var controller = App.KerberosWizardStep4Controller.create({});
     it('should create instance of App.ServiceConfig', function() {
-      expect(controller.createServiceConfig([], [])).be.instanceof(App.ServiceConfig);
+      controller.createServiceConfig([], []).forEach(function(item){
+        expect(item).be.instanceof(App.ServiceConfig);
+      });
     });
   });
 
@@ -75,32 +74,33 @@ describe('App.KerberosWizardStep4Controller', function() {
     var properties = Em.A([
       Em.Object.create({ name: 'realm', value: '', serviceName: 'Cluster' }),
       Em.Object.create({ name: 'spnego_keytab', value: 'spnego_keytab_value', serviceName:
'Cluster' }),
-      Em.Object.create({ name: 'hdfs_keytab', value: '', serviceName: 'HDFS', observesValueFrom:
'spnego_keytab' }),
+      Em.Object.create({ name: 'hdfs_keytab', value: '', serviceName: 'HDFS', identityType:
'user', observesValueFrom: 'spnego_keytab' }),
       Em.Object.create({ name: 'falcon_keytab', value: 'falcon_keytab_value', serviceName:
'FALCON' }),
       Em.Object.create({ name: 'mapreduce_keytab', value: 'mapreduce_keytab_value', serviceName:
'MAPREDUCE2' }),
-      Em.Object.create({ name: 'hdfs_principal', value: 'hdfs_principal_value', serviceName:
'HDFS' })
+      Em.Object.create({ name: 'hdfs_principal', value: 'hdfs_principal_value', identityType:
'user', serviceName: 'HDFS' })
     ]);
     
     var propertyValidationCases = [
       {
         property: 'spnego_keytab',
         e: [
-          { key: 'category', value: 'General' },
-          { key: 'observesValueFrom', absent: true },
+          { key: 'category', value: 'Global' },
+          { key: 'observesValueFrom', absent: true }
         ]
       },
       {
         property: 'realm',
         e: [
-          { key: 'category', value: 'General' },
-          { key: 'value', value: 'realm_value' },
+          { key: 'category', value: 'Global' },
+          { key: 'value', value: 'realm_value' }
         ]
       },
       {
         property: 'hdfs_keytab',
         e: [
+          {key: 'category', value: 'Ambari Principals'},
           { key: 'value', value: 'spnego_keytab_value' },
-          { key: 'observesValueFrom', value: 'spnego_keytab' },
+          { key: 'observesValueFrom', value: 'spnego_keytab' }
         ]
       }
     ];
@@ -144,7 +144,7 @@ describe('App.KerberosWizardStep4Controller', function() {
           }),
           Em.Object.create({
             serviceName: 'HDFS',
-            configCategories: [],
+            configCategories: []
           }),
           Em.Object.create({
             serviceName: 'MAPREDUCE2'
@@ -167,13 +167,13 @@ describe('App.KerberosWizardStep4Controller', function() {
               return Em.A([
                 Em.Object.create({ name: 'realm', value: 'realm_value' }),
                 Em.Object.create({ name: 'admin_principal', value: 'some_val1', defaultValue:
'some_val1', filename: 'krb5-conf.xml' }),
-                Em.Object.create({ name: 'admin_password', value: 'some_password', defaultValue:
'some_password', filename: 'krb5-conf.xml' }),
+                Em.Object.create({ name: 'admin_password', value: 'some_password', defaultValue:
'some_password', filename: 'krb5-conf.xml' })
               ]);
             }
           })
         });
         controller.setStepConfigs(properties);
-        this.result = controller.get('stepConfigs')[0].get('configs');
+        this.result = controller.get('stepConfigs')[0].get('configs').concat(controller.get('stepConfigs')[1].get('configs'));
       });
 
       after(function() {
@@ -199,7 +199,7 @@ describe('App.KerberosWizardStep4Controller', function() {
       ];
       
       propertiesEditableTests.forEach(function(test) {
-        it('Add Service: property `{0}` should be {1}editable'.format(test.name, !!test.e
? '' : 'not '), function() {
+        it('Add Service: property `{0}` should be {1} editable'.format(test.name, !!test.e
? '' : 'not '), function() {
           expect(this.result.findProperty('name', test.name).get('isEditable')).to.eql(test.e);
         });
       });


Mime
View raw message