Repository: ambari
Updated Branches:
  refs/heads/trunk f2be7c501 -> d935afd25


AMBARI-11375. Hdfs, Yarn Hbase and other services ask required passwords for 
Ranger even if Ranger is not installed. (akovalenko)


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

Branch: refs/heads/trunk
Commit: d935afd2578e08dcc5aceafadc38ba0933f95186
Parents: f2be7c5
Author: Aleksandr Kovalenko <akovale...@hortonworks.com>
Authored: Mon May 25 21:45:13 2015 +0300
Committer: Aleksandr Kovalenko <akovale...@hortonworks.com>
Committed: Tue May 26 13:02:20 2015 +0300

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  3 ++
 .../app/controllers/wizard/step7_controller.js  |  4 +++
 ambari-web/app/utils/config.js                  | 23 ++++++++++++++
 .../test/controllers/wizard/step7_test.js       | 14 +++++++++
 ambari-web/test/utils/config_test.js            | 33 ++++++++++++++++++++
 5 files changed, 77 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d935afd2/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js 
b/ambari-web/app/controllers/main/service/info/configs.js
index 5e49ae8..5c23c50 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -844,6 +844,9 @@ App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.ServerValidatorM
     this.checkOverrideProperty(selectedService);
     this.checkDatabaseProperties(selectedService);
     this.checkForSecureConfig(this.get('selectedService'));
+    if (!App.Service.find().someProperty('serviceName', 'RANGER')) {
+      App.config.removeRangerConfigs(this.get('stepConfigs'));
+    }
     this.getRecommendationsForDependencies(null, true, function() {
       self.setProperties({
         dataIsLoaded: true,

http://git-wip-us.apache.org/repos/asf/ambari/blob/d935afd2/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 b8771e5..47f69bd 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -647,6 +647,10 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
         }
       });
 
+      var rangerService = App.StackService.find().findProperty('serviceName', 
'RANGER');
+      if (!rangerService.get('isInstalled') && 
!rangerService.get('isSelected')) {
+        App.config.removeRangerConfigs(self.get('stepConfigs'));
+      }
       self.updateDependentConfigs();
       self.checkHostOverrideInstaller();
       self.activateSpecialConfigs();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d935afd2/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index a7fd14c..a069a72 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1588,6 +1588,29 @@ App.config = Em.Object.create({
       });
       return !!matchingConfigType;
     }
+  },
+
+  /**
+   * Remove all ranger-related configs, that should be available only if 
Ranger is installed
+   * @param configs - stepConfigs object
+   */
+  removeRangerConfigs: function (configs) {
+    configs.forEach(function (service) {
+      var filteredConfigs = [];
+      service.get('configs').forEach(function (config) {
+        if (!/^ranger-/.test(config.get('filename'))) {
+          filteredConfigs.push(config);
+        }
+      });
+      service.set('configs', filteredConfigs);
+      var filteredCategories = [];
+      service.get('configCategories').forEach(function (category) {
+        if (!/ranger-/.test(category.get('name'))) {
+          filteredCategories.push(category);
+        }
+      });
+      service.set('configCategories', filteredCategories);
+    });
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/d935afd2/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 acd3fbf..bda32f5 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1464,6 +1464,19 @@ describe('App.InstallerStep7Controller', function () {
       sinon.stub(installerStep7Controller, 'selectProperService', Em.K);
       sinon.stub(installerStep7Controller, 'setStepConfigs', Em.K);
       sinon.stub(App.router, 'send', Em.K);
+      sinon.stub(App.StackService, 'find', function () {
+        return {
+          findProperty: function () {
+            return Em.Object.create({
+              isInstalled: true,
+              isSelected: false
+            });
+          },
+          filterProperty: function () {
+            return [];
+          }
+        }
+      });
     });
     afterEach(function () {
       App.config.fileConfigsIntoTextarea.restore();
@@ -1474,6 +1487,7 @@ describe('App.InstallerStep7Controller', function () {
       installerStep7Controller.selectProperService.restore();
       installerStep7Controller.setStepConfigs.restore();
       App.router.send.restore();
+      App.StackService.find.restore();
     });
 
     it('should run some methods' , function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d935afd2/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js 
b/ambari-web/test/utils/config_test.js
index d382a60..48e27d1 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -1266,4 +1266,37 @@ describe('App.config', function () {
 
   });
 
+  describe('#removeRangerConfigs', function () {
+
+    it('should remove ranger configs and categories', function () {
+      var configs = [
+        Em.Object.create({
+          configs: [
+            Em.Object.create({filename: 'filename'}),
+            Em.Object.create({filename: 'ranger-filename'})
+          ],
+          configCategories: [
+            Em.Object.create({name: 'ranger-name'}),
+            Em.Object.create({name: 'name'}),
+            Em.Object.create({name: 'also-ranger-name'})
+          ]
+        })
+      ];
+      App.config.removeRangerConfigs(configs);
+      expect(configs).eql(
+          [
+            Em.Object.create({
+              configs: [
+                Em.Object.create({filename: 'filename'})
+              ],
+              configCategories: [
+                Em.Object.create({name: 'name'})
+              ]
+            })
+          ]
+      );
+    });
+
+  });
+
 });

Reply via email to