ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject git commit: AMBARI-4162. Ambari trying to setup namenode dirs on nfs mounted home dirs. (onechiporenko)
Date Tue, 24 Dec 2013 15:20:21 GMT
Updated Branches:
  refs/heads/trunk 8860005f9 -> b3659b0f3


AMBARI-4162. Ambari trying to setup namenode dirs on nfs mounted home dirs. (onechiporenko)


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

Branch: refs/heads/trunk
Commit: b3659b0f3f7f6d7bf9ab23771d5c01e33297f5bc
Parents: 8860005
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Tue Dec 24 17:14:31 2013 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Tue Dec 24 17:20:14 2013 +0200

----------------------------------------------------------------------
 ambari-web/app/models/service_config.js | 14 +++++++-------
 ambari-web/app/utils/validator.js       | 15 +++++++++++++++
 ambari-web/test/utils/validator_test.js | 18 ++++++++++++++++++
 3 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b3659b0f/ambari-web/app/models/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js
index f29e072..40568c8 100644
--- a/ambari-web/app/models/service_config.js
+++ b/ambari-web/app/models/service_config.js
@@ -229,7 +229,6 @@ App.ServiceConfigProperty = Ember.Object.extend({
     types.forEach(function(type) {
       if (type === displayType) {
         result = true;
-        return;
       }
     });
     return result;
@@ -664,16 +663,17 @@ App.ServiceConfigProperty = Ember.Object.extend({
         case 'checkbox':
           break;
         case 'directories':
-          if (!validator.isValidDir(value)) {
-            this.set('errorMessage', 'Must be a slash at the start');
-            isError = true;
-          }
-          break;
         case 'directory':
           if (!validator.isValidDir(value)) {
             this.set('errorMessage', 'Must be a slash at the start');
             isError = true;
           }
+          else {
+            if (!validator.isAllowedDir(value)) {
+              this.set('errorMessage', 'Can\'t start with "home(s)"');
+              isError = true;
+            }
+          }
           break;
         case 'custom':
           break;
@@ -691,7 +691,7 @@ App.ServiceConfigProperty = Ember.Object.extend({
           break;
         case 'host':
           var hiveOozieHostNames = ['hive_hostname','hive_existing_mysql_host','hive_existing_oracle_host','hive_ambari_host',
-          'oozie_hostname','oozie_existing_mysql_host','oozie_existing_oracle_host','oozie_ambari_host']
+          'oozie_hostname','oozie_existing_mysql_host','oozie_existing_oracle_host','oozie_ambari_host'];
           if(hiveOozieHostNames.contains(this.get('name'))) {
             if (validator.hasSpaces(value)) {
               this.set('errorMessage', Em.I18n.t('host.spacesValidation'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3659b0f/ambari-web/app/utils/validator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/validator.js b/ambari-web/app/utils/validator.js
index e161f0f..b5b850d 100644
--- a/ambari-web/app/utils/validator.js
+++ b/ambari-web/app/utils/validator.js
@@ -57,6 +57,21 @@ module.exports = {
   },
 
   /**
+   * validate directory doesn't start "home" or "homes"
+   * @param value
+   * @returns {boolean}
+   */
+  isAllowedDir: function(value) {
+    var dirs = value.replace(/,/g,' ').trim().split(new RegExp("\\s+", "g"));
+    for(var i = 0; i < dirs.length; i++){
+      if(dirs[i].startsWith('/home') || dirs[i].startsWith('/homes')) {
+        return false;
+      }
+    }
+    return true;
+  },
+
+  /**
    * validate ip address with port
    * @param value
    * @return {Boolean}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3659b0f/ambari-web/test/utils/validator_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/validator_test.js b/ambari-web/test/utils/validator_test.js
index 7b7159a..2882a10 100644
--- a/ambari-web/test/utils/validator_test.js
+++ b/ambari-web/test/utils/validator_test.js
@@ -256,6 +256,24 @@ describe('validator', function () {
       })
     });
   })
+  describe('#isAllowedDir(value)', function() {
+    var tests = [
+      {m:'"/home" - not allowed',i:'/home',e:false},
+      {m:'"/homes" - not allowed',i:'/homes',e:false},
+      {m:'"/home/" - not allowed',i:'/home/',e:false},
+      {m:'"/homes/" - not allowed',i:'/homes/',e:false},
+      {m:'"/dir" - allowed',i:'/dir',e:true},
+      {m:'"/dir/home" - allowed',i:'/dir/home',e:true},
+      {m:'"/dir/homes" - allowed',i:'/dir/homes',e:true},
+      {m:'"/dir/home/" - allowed',i:'/dir/home/',e:true},
+      {m:'"/dir/homes/" - allowed',i:'/dir/homes/',e:true}
+    ];
+    tests.forEach(function(test) {
+      it(test.m + ' ', function () {
+        expect(validator.isAllowedDir(test.i)).to.equal(test.e);
+      })
+    });
+  })
   describe('#isValidConfigKey(value)', function() {
     var tests = [
       {m:'"123" - valid',i:'123',e:true},


Mime
View raw message