incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject svn commit: r1467022 - in /incubator/ambari/trunk: ./ ambari-web/app/assets/data/configurations/ ambari-web/app/models/ ambari-web/app/utils/ ambari-web/app/views/common/configs/
Date Thu, 11 Apr 2013 18:09:15 GMT
Author: yusaku
Date: Thu Apr 11 18:09:14 2013
New Revision: 1467022

URL: http://svn.apache.org/r1467022
Log:
AMBARI-1876. Capacity Scheduler: implement user/group and admin user/group validation rules.
(yusaku)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/assets/data/configurations/cluster_level_configs.json
    incubator/ambari/trunk/ambari-web/app/models/service_config.js
    incubator/ambari/trunk/ambari-web/app/utils/config.js
    incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1467022&r1=1467021&r2=1467022&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Apr 11 18:09:14 2013
@@ -241,6 +241,9 @@ Trunk (unreleased changes):
 
  IMPROVEMENTS
 
+ AMBARI-1876. Capacity Scheduler: implement user/group and admin user/group
+ validation rules. (yusaku)
+
  AMBARI-1864. Remove package dependency on mocha-phantomjs. (yusaku)
 
  AMBARI-1844. Need ability to update multiple hosts in 1 PUT call.

Modified: incubator/ambari/trunk/ambari-web/app/assets/data/configurations/cluster_level_configs.json
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/assets/data/configurations/cluster_level_configs.json?rev=1467022&r1=1467021&r2=1467022&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/assets/data/configurations/cluster_level_configs.json
(original)
+++ incubator/ambari/trunk/ambari-web/app/assets/data/configurations/cluster_level_configs.json
Thu Apr 11 18:09:14 2013
@@ -143,10 +143,10 @@
         "cluster_name" : "vmc"
       },
       "properties" : {
-        "mapred.queue.default.acl-submit-job" : "* *",
-        "mapred.queue.default.acl-administer-jobs" : "* *",
-        "mapred.queue.new_qeuue.acl-administer-jobs" : "* *",
-        "mapred.queue.new_qeuue.acl-submit-job" : "* *"
+        "mapred.queue.default.acl-submit-job" : "*",
+        "mapred.queue.default.acl-administer-jobs" : "*",
+        "mapred.queue.new_qeuue.acl-administer-jobs" : "*",
+        "mapred.queue.new_qeuue.acl-submit-job" : "*"
       }
     },
     {

Modified: incubator/ambari/trunk/ambari-web/app/models/service_config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/models/service_config.js?rev=1467022&r1=1467021&r2=1467022&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/models/service_config.js (original)
+++ incubator/ambari/trunk/ambari-web/app/models/service_config.js Thu Apr 11 18:09:14 2013
@@ -474,7 +474,11 @@ App.ServiceConfigProperty = Ember.Object
             values = value.split(',');
             for(var i = 0, l = values.length; i < l; i++){
               if(!validator.isValidUNIXUser(values[i])){
-                this.set('errorMessage', 'Must be a valid list of user names');
+                if(this.get('type') == 'USERS'){
+                  this.set('errorMessage', 'Must be a valid list of user names');
+                } else {
+                  this.set('errorMessage', 'Must be a valid list of group names');
+                }
                 isError = true;
               }
             }

Modified: incubator/ambari/trunk/ambari-web/app/utils/config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/config.js?rev=1467022&r1=1467021&r2=1467022&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/config.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/config.js Thu Apr 11 18:09:14 2013
@@ -172,7 +172,7 @@ App.config = Em.Object.create({
    */
   mergePreDefinedWithStored: function (storedConfigs) {
     var mergedConfigs = [];
-    var preDefinedConfigs = this.get('preDefinedConfigProperties');
+    var preDefinedConfigs = $.extend(true, [], this.get('preDefinedConfigProperties'));
     var preDefinedNames = [];
     var storedNames = [];
     var names = [];
@@ -314,10 +314,10 @@ App.config = Em.Object.create({
         customConfig.value = 'false';
         break;
       case 'mapred.queue.' + queueName + '.acl-submit-job':
-        customConfig.value = '* *';
+        customConfig.value = '*';
         break;
       case 'mapred.queue.' + queueName + '.acl-administer-jobs':
-        customConfig.value = '* *';
+        customConfig.value = '*';
         break;
     }
   },
@@ -477,7 +477,7 @@ App.config = Em.Object.create({
           name: item.property_name,
           value: item.property_value,
           description: item.property_description,
-          filename: item.filename
+          filename: item.filename || item.type
         });
       }, this);
       serviceComponents[data.items[0].StackConfigurations.service_name] = properties;

Modified: incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js?rev=1467022&r1=1467021&r2=1467022&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js (original)
+++ incubator/ambari/trunk/ambari-web/app/views/common/configs/services_config.js Thu Apr
11 18:09:14 2013
@@ -994,6 +994,7 @@ App.ServiceConfigCapacityScheduler = App
        * @return {*}
        */
       insertExtraConfigs: function(content){
+        var that = this;
         var admin = content.configs.findProperty('name', 'mapred.queue.' + content.name +
'.acl-administer-jobs').get('value');
         var submit = content.configs.findProperty('name', 'mapred.queue.' + content.name
+ '.acl-submit-job').get('value');
         admin = (admin) ? admin.split(' ') : [''];
@@ -1044,7 +1045,8 @@ App.ServiceConfigCapacityScheduler = App
         });
         newField.validate();
         content.configs.unshift(newField);
-        newField = App.ServiceConfigProperty.create({
+
+        var submitUser = App.ServiceConfigProperty.create({
           name: 'mapred.queue.' + content.name + '.acl-submit-job',
           displayName: Em.I18n.t('common.users'),
           value: submit[0],
@@ -1055,22 +1057,8 @@ App.ServiceConfigCapacityScheduler = App
           displayType: "UNIXList",
           index: 3
         });
-        newField.validate();
-        content.configs.push(newField);
-        newField = App.ServiceConfigProperty.create({
-          name: 'mapred.queue.' + content.name + '.acl-administer-jobs',
-          displayName: Em.I18n.t('services.mapReduce.config.queue.adminUsers'),
-          description: Em.I18n.t('services.mapReduce.description.queue.admin.user'),
-          value: admin[0],
-          isRequired: true,
-          isVisible: true,
-          type: 'USERS',
-          displayType: "UNIXList",
-          index: 5
-        });
-        newField.validate();
-        content.configs.push(newField);
-        newField = App.ServiceConfigProperty.create({
+
+        var submitGroup = App.ServiceConfigProperty.create({
           name: 'mapred.queue.' + content.name + '.acl-submit-job',
           displayName: Em.I18n.t('services.mapReduce.config.queue.groups'),
           description: Em.I18n.t('services.mapReduce.description.queue.submit.group'),
@@ -1081,9 +1069,20 @@ App.ServiceConfigCapacityScheduler = App
           type: 'GROUPS',
           index: 4
         });
-        newField.validate();
-        content.configs.push(newField);
-        newField = App.ServiceConfigProperty.create({
+
+        var adminUser = App.ServiceConfigProperty.create({
+          name: 'mapred.queue.' + content.name + '.acl-administer-jobs',
+          displayName: Em.I18n.t('services.mapReduce.config.queue.adminUsers'),
+          description: Em.I18n.t('services.mapReduce.description.queue.admin.user'),
+          value: admin[0],
+          isRequired: true,
+          isVisible: true,
+          type: 'USERS',
+          displayType: "UNIXList",
+          index: 5
+        });
+
+        var adminGroup = App.ServiceConfigProperty.create({
           name: 'mapred.queue.' + content.name + '.acl-administer-jobs',
           displayName: Em.I18n.t('services.mapReduce.config.queue.adminGroups'),
           value: admin[1],
@@ -1094,10 +1093,42 @@ App.ServiceConfigCapacityScheduler = App
           type: 'GROUPS',
           index: 6
         });
-        newField.validate();
-        content.configs.push(newField);
+
+        submitUser.reopen({
+          validate: function(){
+            that.userGroupValidation(this, submitGroup);
+          }.observes('value')
+        });
+        submitGroup.reopen({
+          validate: function(){
+            that.userGroupValidation(this, submitUser);
+          }.observes('value')
+        });
+        adminUser.reopen({
+          validate: function(){
+            that.userGroupValidation(this, adminGroup);
+          }.observes('value')
+        });
+        adminGroup.reopen({
+          validate: function(){
+            that.userGroupValidation(this, adminUser);
+          }.observes('value')
+        });
+
+        submitUser.validate();
+        adminUser.validate();
+        content.configs.push(submitUser);
+        content.configs.push(submitGroup);
+        content.configs.push(adminUser);
+        content.configs.push(adminGroup);
+
         return content;
       },
+      /**
+       * sort properties of queue by index
+       * @param configs
+       * @return {Array}
+       */
       sortQueueProperties: function(configs){
         var sortedConfigs = [];
         var skippedConfigs = [];
@@ -1109,6 +1140,27 @@ App.ServiceConfigCapacityScheduler = App
           }
         });
         return sortedConfigs.concat(skippedConfigs);
+      },
+      /**
+       * Validate by follow rules:
+       * Users can be blank. If this is blank, Groups must not be blank.
+       * Groups can be blank. If this is blank, Users must not be blank.
+       * @param context
+       * @param boundConfig
+       */
+      userGroupValidation:  function(context, boundConfig){
+        if(context.get('value') == ''){
+          if(boundConfig.get('value') == ''){
+            context._super();
+          } else {
+            boundConfig.validate();
+          }
+        } else {
+          if(boundConfig.get('value') == ''){
+            boundConfig.set('errorMessage', '');
+          }
+          context._super();
+        }
       }
     })
   }



Mime
View raw message