ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [2/2] ambari git commit: AMBARI-8200 Add Service wizard: Custom properties with empty values should not be be marked erroneous. (Buzhor Denys via ababiichuk)
Date Fri, 07 Nov 2014 13:08:55 GMT
AMBARI-8200 Add Service wizard: Custom properties with empty values should not be be marked
erroneous. (Buzhor Denys via ababiichuk)


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

Branch: refs/heads/branch-1.7.0
Commit: b7a2691ef1d0495fd8cf717301a17b0fa20d777a
Parents: a85ca52
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Fri Nov 7 14:48:24 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Fri Nov 7 14:48:24 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 34 ++++++++++++++++--
 ambari-web/app/data/HDP2/secure_mapping.js      |  3 +-
 .../test/controllers/wizard/step7_test.js       | 38 ++++++++++++++++++--
 3 files changed, 70 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b7a2691e/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 645d435..1ba415a 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -51,7 +51,13 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
{
   /**
    * used in services_config.js view to mark a config with security icon
    */
-  secureConfigs: require('data/secure_mapping'),
+  secureConfigs: function() {
+    if (App.get('isHadoop2Stack')) {
+      return require('data/HDP2/secure_mapping');
+    } else {
+      return require('data/secure_mapping');
+    }
+  }.property('isHadoop2Stack'),
 
   /**
    * config categories with secure properties
@@ -829,7 +835,12 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
{
           this.addSecureConfigs(selectedService, serviceName) ;
         }
       }, this);
-
+      this.get('installedServiceNames').forEach(function(serviceName) {
+        var serviceConfigObj = serviceConfigs.findProperty('serviceName', serviceName);
+        if (this.get('securityEnabled')) {
+          this.setSecureConfigs(serviceConfigObj, serviceName);
+        }
+      }, this);
       // Remove SNameNode if HA is enabled
       if (App.get('isHaEnabled')) {
         var c = serviceConfigs.findProperty('serviceName', 'HDFS').configs;
@@ -845,6 +856,25 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
{
   },
 
   /**
+   * Set secure properties for installed services. Mark secure properties and 
+   * properties with default empty value as non required to pass validation.
+   *
+   * @param {Em.Object} serviceConfigObj
+   * @param {String} serviceName
+   */
+  setSecureConfigs: function(serviceConfigObj, serviceName) {
+    var configProperties = serviceConfigObj.get('configs');
+    if (!configProperties) return;
+    var secureConfigs = this.get('secureConfigs').filterProperty('serviceName', serviceName);
+    secureConfigs.forEach(function(secureConfig) {
+      var property = configProperties.findProperty('name', secureConfig.name);
+      if (property) {
+        property.set('isRequired', secureConfig.value != "");
+        if (!property.get('isRequired')) property.set('errorMessage', '');
+      }
+    });
+  },
+  /**
    *
    * @param selectedService
    * @param serviceName

http://git-wip-us.apache.org/repos/asf/ambari/blob/b7a2691e/ambari-web/app/data/HDP2/secure_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/secure_mapping.js b/ambari-web/app/data/HDP2/secure_mapping.js
index 6299bce..f4a17d9 100644
--- a/ambari-web/app/data/HDP2/secure_mapping.js
+++ b/ambari-web/app/data/HDP2/secure_mapping.js
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+var App = require('app');
 // All of the "name" properties have to coincide with how they will appear in the *-site.xml
file
 // The "template" properties can come from the config properties in site_properties.js or
secure_properties.js .
 var props = [
@@ -921,7 +922,7 @@ var yarn22Mapping = [
     "value": "",
     "templateName": [],
     "foreignKey": null,
-    "serviceName": "YARN",
+    "serviceName": "HDFS",
     "filename": "core-site.xml"
   },
   {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b7a2691e/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index d405426..1f0f7fc 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -333,7 +333,7 @@ describe('App.InstallerStep7Controller', function () {
     it('should set property to false', function () {
       var allSelectedServiceNames = ['YARN'],
         configs = [
-          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true},
+          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
         ],
         expected = [
           {name: 'hadoop.registry.rm.enabled', value: false, defaultValue: false, forceUpdate:
true}
@@ -346,7 +346,7 @@ describe('App.InstallerStep7Controller', function () {
     it('should skip setting property', function () {
       var allSelectedServiceNames = ['YARN', 'SLIDER'],
         configs = [
-          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true},
+          {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
         ],
         expected = [
           {name: 'hadoop.registry.rm.enabled', value: true, defaultValue: true}
@@ -1270,4 +1270,38 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
+  describe('#setSecureConfigs', function() {
+    var serviceConfigObj = Em.Object.create({
+      serviceName: 'HDFS',
+      configs: [
+        Em.Object.create({ name: 'hadoop.http.authentication.signature.secret.file' }),
+        Em.Object.create({ name: 'hadoop.security.authentication' })
+      ]
+    });
+    var tests = [
+      { name: 'hadoop.http.authentication.signature.secret.file', e: false },
+      { name: 'hadoop.security.authentication', e: true }
+    ];
+
+    sinon.stub(App, 'get', function(key) {
+      if (['isHadoop22Stack', 'isHadoop2Stack'].contains(key)) return true;
+      else App.get(key);
+    });
+    var controller = App.WizardStep7Controller.create({});
+    controller.get('secureConfigs').pushObjects([
+      {
+        name: 'hadoop.http.authentication.signature.secret.file',
+        serviceName: 'HDFS',
+        value: ''
+      }
+    ]);
+    controller.setSecureConfigs(serviceConfigObj, 'HDFS');
+    App.get.restore();
+    tests.forEach(function(test) {
+      it('{0} is {1}required'.format(test.name, !!test.e ? '' : 'non ' ), function() {
+        expect(serviceConfigObj.get('configs').findProperty('name', test.name).get('isRequired')).to.eql(test.e);
+      });
+    });
+  });
+
 });


Mime
View raw message