ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [2/4] ambari git commit: AMBARI-12692. Map config properties for PHD stack version to HDP stack version (alexantonenko)
Date Tue, 11 Aug 2015 08:38:52 GMT
http://git-wip-us.apache.org/repos/asf/ambari/blob/89f4162b/ambari-web/app/data/custom_stack_map.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/custom_stack_map.js b/ambari-web/app/data/custom_stack_map.js
new file mode 100644
index 0000000..1834ead
--- /dev/null
+++ b/ambari-web/app/data/custom_stack_map.js
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var App = require('app');
+
+/*
+sign will be compared like: <clusterSelectedStackVersion> sign <stackVersionNumber>
if true use this baseStackFolder
+Example:
+ {
+ "stackName": "PHD",
+ "stackVersionNumber": "3.0",
+ "sign": "<",
+ "baseStackFolder": "HDP2"
+ }
+ This rule will work for any PHD version number that is lower than 3.0 (2.9,2.8, e.t.c)
+*/
+
+module.exports = [
+  {
+    "stackName": "PHD",
+    "stackVersionNumber": "3.1",
+    "sign": "=",
+    "baseStackFolder": "HDP2.3"
+  },
+  {
+    "stackName": "PHD",
+    "stackVersionNumber": "3.0",
+    "sign": "=",
+    "baseStackFolder": "HDP2.2"
+  },
+  {
+    "stackName": "PHD",
+    "stackVersionNumber": "3.0",
+    "sign": "<",
+    "baseStackFolder": "HDP2"
+  }
+];
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/89f4162b/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 7e6e574..04a8345 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -132,8 +132,33 @@ App.config = Em.Object.create({
 
   configMapping: require('data/HDP2/config_mapping'),
 
+  customStackMapping: require('data/custom_stack_map'),
+
+  mapCustomStack: function () {
+    var
+      baseStackFolder = App.get('currentStackName'),
+      singMap = {
+        "1": ">",
+        "-1": "<",
+        "0": "="
+      };
+
+    this.get('customStackMapping').every(function (stack) {
+      if(stack.stackName == App.get('currentStackName')){
+        var versionCompare = Em.compare(App.get('currentStackVersionNumber'), stack.stackVersionNumber);
+        if(singMap[versionCompare+""] === stack.sign){
+          baseStackFolder = stack.baseStackFolder;
+          return false;
+        }
+      }
+      return true;
+    });
+
+    return baseStackFolder;
+  },
+
   allPreDefinedSiteProperties: function() {
-    var sitePropertiesForCurrentStack = this.preDefinedConfigFile('site_properties');
+    var sitePropertiesForCurrentStack = this.preDefinedConfigFile(this.mapCustomStack(),
'site_properties');
     if (sitePropertiesForCurrentStack) {
       return sitePropertiesForCurrentStack.configProperties;
     } else if (App.get('isHadoop23Stack')) {
@@ -165,9 +190,9 @@ App.config = Em.Object.create({
     return map;
   }.property('preDefinedSiteProperties'),
 
-  preDefinedConfigFile: function(file) {
+  preDefinedConfigFile: function(folder, file) {
     try {
-      return require('data/{0}/{1}'.format(App.get('currentStackName'), file));
+      return require('data/{0}/{1}'.format(folder, file));
     } catch (err) {
       // the file doesn't exist, which might be expected.
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/89f4162b/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index bdd382f..a6fca43 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -315,7 +315,7 @@ describe('App.config', function () {
     });
 
     it('bigtop site properties should be ok.', function() {
-      var bigtopSiteProperties = App.config.preDefinedConfigFile('site_properties');
+      var bigtopSiteProperties = App.config.preDefinedConfigFile('BIGTOP', 'site_properties');
       expect(bigtopSiteProperties).to.be.ok;
     });
 


Mime
View raw message