Prechádzať zdrojové kódy

AMBARI-11964. Allow services to hide "custom" configurations. (Di Li via Jaimin)

Jaimin Jetly 9 rokov pred
rodič
commit
eac8a0ce54
18 zmenil súbory, kde vykonal 110 pridanie a 20 odobranie
  1. 1 1
      ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml
  2. 1 1
      ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml
  3. 1 1
      ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml
  4. 1 1
      ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml
  5. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml
  6. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml
  7. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml
  8. 1 1
      ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml
  9. 1 1
      ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml
  10. 1 1
      ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml
  11. 1 1
      ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml
  12. 1 1
      ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml
  13. 1 2
      ambari-web/app/models/stack_service.js
  14. 22 1
      ambari-web/app/utils/config.js
  15. 2 1
      ambari-web/app/views/common/configs/service_config_view.js
  16. 1 0
      ambari-web/app/views/common/configs/service_configs_by_category_view.js
  17. 60 0
      ambari-web/test/utils/config_test.js
  18. 12 4
      ambari-web/test/views/common/configs/service_config_view_test.js

+ 1 - 1
ambari-server/src/main/resources/common-services/FLUME/1.4.0.2.0/configuration/flume-conf.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Flume agent configurations. 

+ 1 - 1
ambari-server/src/main/resources/common-services/PIG/0.12.0.2.0/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/FLUME/configuration/flume-conf.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

+ 1 - 1
ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.0.6.GlusterFS/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.1.GlusterFS/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.1/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDP/2.3/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 1
ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/FLUME/configuration/flume-conf.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Flume agent configurations. 

+ 1 - 1
ambari-server/src/test/resources/stacks/HDP/2.0.6.1/services/FLUME/configuration/flume-conf.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

+ 1 - 1
ambari-server/src/test/resources/stacks/HDP/2.0.6/services/FLUME/configuration/flume-conf.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
   <property>
     <name>content</name>
     <description>Describe all the Flume agent configurations</description>

+ 1 - 1
ambari-server/src/test/resources/stacks/HDP/2.1.1/services/PIG/configuration/pig-properties.xml

@@ -20,7 +20,7 @@
  */
 -->
 
-<configuration supports_final="false">
+<configuration supports_final="false" supports_adding_forbidden="true">
 
   <property>
     <name>content</name>

+ 1 - 2
ambari-web/app/models/stack_service.js

@@ -371,8 +371,7 @@ App.StackService.configCategories = function () {
 
   // Add custom section for every configType to all the services
   configTypes.forEach(function (type) {
-    var configTypesWithNoCustomSection = ['capacity-scheduler','mapred-queue-acls','flume-conf', 'pig-properties','topology','users-ldif', 'admin-topology', 'knoxsso-topology'];
-    if (type.endsWith('-env') || type.endsWith('-log4j') || configTypesWithNoCustomSection.contains(type)) {
+    if (type.endsWith('-env') || type.endsWith('-log4j')) {
       return;
     }
     serviceConfigCategories.pushObject(App.ServiceConfigCategory.create({

+ 22 - 1
ambari-web/app/utils/config.js

@@ -278,6 +278,7 @@ App.config = Em.Object.create({
       recommendedValue: null,
       recommendedIsFinal: null,
       supportsFinal: this.shouldSupportFinal(serviceName, fileName),
+      supportsAddingForbidden: this.shouldSupportAddingForbidden(serviceName, fileName),
       serviceName: serviceName,
       displayName: name,
       displayType: this.getDefaultDisplayType(coreObject ? coreObject.value : ''),
@@ -580,7 +581,8 @@ App.config = Em.Object.create({
     var configTypes = service.get('configTypes');
     var configTypesInfo = {
       items: [],
-      supportsFinal: []
+      supportsFinal: [],
+      supportsAddingForbidden: []
     };
     if (configTypes) {
       for (var key in configTypes) {
@@ -589,6 +591,9 @@ App.config = Em.Object.create({
           if (configTypes[key].supports && configTypes[key].supports.final === "true") {
             configTypesInfo.supportsFinal.push(key);
           }
+          if (configTypes[key].supports && configTypes[key].supports.adding_forbidden === "true"){
+            configTypesInfo.supportsAddingForbidden.push(key);
+          }
         }
       }
     }
@@ -917,6 +922,22 @@ App.config = Em.Object.create({
     }
   },
 
+  shouldSupportAddingForbidden: function(serviceName, filename) {
+    var unsupportedServiceNames = ['MISC', 'Cluster'];
+    if (!serviceName || unsupportedServiceNames.contains(serviceName) || !filename) {
+      return false;
+    } else {
+      var stackServiceName = App.StackService.find().findProperty('serviceName', serviceName);
+      if (!stackServiceName) {
+        return false;
+      }
+      var stackService = App.StackService.find(serviceName);
+      return !!this.getConfigTypesInfoFromService(stackService).supportsAddingForbidden.find(function (configType) {
+        return filename.startsWith(configType);
+      });
+    }
+  },
+
   /**
    * Remove all ranger-related configs, that should be available only if Ranger is installed
    * @param configs - stepConfigs object

+ 2 - 1
ambari-web/app/views/common/configs/service_config_view.js

@@ -152,7 +152,8 @@ App.ServiceConfigView = Em.View.extend({
 
     if (controller.get('selectedConfigGroup')) {
       controller.get('selectedService.configCategories').filterProperty('siteFileName').forEach(function (config) {
-        config.set('customCanAddProperty', config.get('canAddProperty'));
+        var supportsAddingForbidden = App.config.shouldSupportAddingForbidden(controller.get('selectedService').serviceName, config.siteFileName); //true if the UI should not display the Custom ... section
+        config.set('customCanAddProperty', !supportsAddingForbidden);
       });
     }
 

+ 1 - 0
ambari-web/app/views/common/configs/service_configs_by_category_view.js

@@ -354,6 +354,7 @@ App.ServiceConfigsByCategoryView = Em.View.extend(App.UserPref, App.ConfigOverri
       savedValue: null,
       recommendedValue: null,
       supportsFinal: App.config.shouldSupportFinal(propertyObj.serviceName, propertyObj.filename),
+      supportsAddingForbidden: false, //Can add a new property implies the given categrary allows adding new properties...
       filename: propertyObj.filename || '',
       isUserProperty: true,
       isNotSaved: true,

+ 60 - 0
ambari-web/test/utils/config_test.js

@@ -469,6 +469,65 @@ describe('App.config', function () {
 
   });
 
+  describe('#shouldSupportAddingForbidden', function () {
+
+    var cases = [
+      {
+        shouldSupportAddingForbidden: false,
+        title: 'no service name specified'
+      },
+      {
+        serviceName: 's0',
+        shouldSupportAddingForbidden: false,
+        title: 'no filename specified'
+      },
+      {
+        serviceName: 'MISC',
+        shouldSupportAddingForbidden: false,
+        title: 'MISC'
+      },
+      {
+        serviceName: 's0',
+        filename: 's0-site',
+        shouldSupportAddingForbidden: true,
+        title: 'adding forbidden supported'
+      },
+      {
+        serviceName: 's0',
+        filename: 's0-properties',
+        shouldSupportAddingForbidden: false,
+        title: 'adding forbidden not supported'
+      }
+    ];
+
+    beforeEach(function () {
+      sinon.stub(App.StackService, 'find').returns([
+        Em.Object.create({
+          serviceName: 's0',
+          configTypes: {
+            's0-size': {},
+            's0-properties': {}
+          }
+        })
+      ]);
+      sinon.stub(App.config, 'getConfigTypesInfoFromService').returns({
+        supportsAddingForbidden: ['s0-site']
+      });
+    });
+
+    afterEach(function () {
+      App.StackService.find.restore();
+      App.config.getConfigTypesInfoFromService.restore();
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        expect(App.config.shouldSupportAddingForbidden(item.serviceName, item.filename)).to.equal(item.shouldSupportAddingForbidden);
+      });
+    });
+
+  });
+
   describe('#removeRangerConfigs', function () {
 
     it('should remove ranger configs and categories', function () {
@@ -783,6 +842,7 @@ describe('App.config', function () {
       recommendedValue: null,
       recommendedIsFinal: null,
       supportsFinal: true,
+      supportsAddingForbidden: false,
       serviceName: 'pServiceName',
       displayName: 'pName',
       displayType: 'pDisplayType',

+ 12 - 4
ambari-web/test/views/common/configs/service_config_view_test.js

@@ -44,8 +44,8 @@ describe('App.ServiceConfigView', function () {
         serviceName: 'TEST',
         configCategories: [
           App.ServiceConfigCategory.create({ name: 'category1', canAddProperty: false}),
-          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'xml', canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'xml', canAddProperty: false})
+          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'category2.xml', canAddProperty: true}),
+          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'category3.xml', canAddProperty: false})
         ],
         configs: []
       }
@@ -62,8 +62,8 @@ describe('App.ServiceConfigView', function () {
         serviceName: 'TEST',
         configCategories: [
           App.ServiceConfigCategory.create({ name: 'category1', canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'xml', canAddProperty: true}),
-          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'xml', canAddProperty: false})
+          App.ServiceConfigCategory.create({ name: 'category2', siteFileName: 'category2.xml', canAddProperty: true}),
+          App.ServiceConfigCategory.create({ name: 'category3', siteFileName: 'category3.xml', canAddProperty: false})
         ],
         configs: []
       }
@@ -71,6 +71,14 @@ describe('App.ServiceConfigView', function () {
   ];
 
   describe('#checkCanEdit', function () {
+    before(function () {
+      sinon.stub(App.config, 'shouldSupportAddingForbidden').withArgs('TEST', 'category2.xml').returns(true).withArgs('TEST', 'category3.xml').returns(false);
+    });
+
+    after(function () {
+      App.config.shouldSupportAddingForbidden.restore();
+    });
+
     testCases.forEach(function (test) {
       it(test.title, function () {
         controller.set('selectedService', test.selectedService);