Repository: ambari
Updated Branches:
  refs/heads/trunk 8c569a8b0 -> bf2a1ec18


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/bf2a1ec1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bf2a1ec1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bf2a1ec1

Branch: refs/heads/trunk
Commit: bf2a1ec1846e8b1bc87b72af539b595dd8df4814
Parents: 8c569a8
Author: Aleksandr Kovalenko <[email protected]>
Authored: Sun May 31 18:46:58 2015 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Sun May 31 18:46:58 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/bf2a1ec1/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 c79897b..c5bcf9f 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -848,6 +848,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/bf2a1ec1/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 92481f9..3cc31f0 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -681,6 +681,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/bf2a1ec1/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 32553e8..1a902bd 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1590,6 +1590,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/bf2a1ec1/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 35bd6d0..72e2753 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/bf2a1ec1/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