Prechádzať zdrojové kódy

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

Aleksandr Kovalenko 10 rokov pred
rodič
commit
bf2a1ec184

+ 3 - 0
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,

+ 4 - 0
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();

+ 23 - 0
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);
+    });
   }
 
 });

+ 14 - 0
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 () {

+ 33 - 0
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'})
+              ]
+            })
+          ]
+      );
+    });
+
+  });
+
 });