You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2015/11/16 16:26:02 UTC

ambari git commit: AMBARI-13904 Ranger Admins users password for Ambari is required to be filled by end user. (ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/trunk af52444f7 -> 5a98a3f95


AMBARI-13904 Ranger Admins users password for Ambari is required to be filled by end user. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 5a98a3f954b66672fab2ab030f94eec55b865589
Parents: af52444
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Mon Nov 16 17:22:42 2015 +0200
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Mon Nov 16 17:22:42 2015 +0200

----------------------------------------------------------------------
 .../app/utils/configs/config_initializer.js       | 15 +++++++++++++++
 ambari-web/app/utils/string_utils.js              | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5a98a3f9/ambari-web/app/utils/configs/config_initializer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/configs/config_initializer.js b/ambari-web/app/utils/configs/config_initializer.js
index ebb9e1a..447e514 100644
--- a/ambari-web/app/utils/configs/config_initializer.js
+++ b/ambari-web/app/utils/configs/config_initializer.js
@@ -18,6 +18,7 @@
 
 var App = require('app');
 require('utils/configs/config_initializer_class');
+var stringUtils = require('utils/string_utils');
 
 /**
  * Regexp for host with port ('hostName:1234')
@@ -264,6 +265,7 @@ App.ConfigInitializer = App.ConfigInitializerClass.create({
   },
 
   uniqueInitializers: {
+    'ranger_admin_password': '_setRangerAdminPassword',
     'hive_database': '_initHiveDatabaseValue',
     'templeton.hive.properties': '_initTempletonHiveProperties',
     'hbase.zookeeper.quorum': '_initHBaseZookeeperQuorum',
@@ -295,6 +297,19 @@ App.ConfigInitializer = App.ConfigInitializerClass.create({
   },
 
   /**
+   * Some strange method that should define <code>ranger_admin_password</code>
+   * TODO DELETE as soon as <code>ranger_admin_password</code> will be defined in stack!
+   *
+   * @param {configProperty} configProperty
+   * @private
+   */
+  _setRangerAdminPassword: function(configProperty) {
+    var value = 'P1!q' + stringUtils.getRandomString(12);
+    Em.setProperties(configProperty, {'value': value, 'recommendedValue': value, 'retypedPassword': value});
+    return configProperty;
+  },
+
+  /**
    * Initializer for configs with value equal to hostName with needed component
    * Value example: 'hostName'
    *

http://git-wip-us.apache.org/repos/asf/ambari/blob/5a98a3f9/ambari-web/app/utils/string_utils.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/string_utils.js b/ambari-web/app/utils/string_utils.js
index 3b14bfc..77e709d 100644
--- a/ambari-web/app/utils/string_utils.js
+++ b/ambari-web/app/utils/string_utils.js
@@ -226,5 +226,23 @@ module.exports = {
    */
   escapeRegExp: function (str) {
     return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
+  },
+
+  /**
+   * Generates random string using upper and lower letters and digits
+   *
+   * @param {number} len
+   * @param {String} [allowed]
+   * @returns {String}
+   * @method getRandomString
+   */
+  getRandomString: function(len, allowed) {
+    Em.assert('len should be defined and more than 0', len > 0);
+    var text = '';
+    allowed = typeof allowed === 'string' ? allowed : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+    for( var i=0; i < len; i++ ) {
+      text += allowed.charAt(Math.floor(Math.random() * allowed.length));
+    }
+    return text;
   }
 };