You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/08/12 19:02:14 UTC

ambari git commit: AMBARI-12746: [PluggableStackDefinition] Generate UI mapping for stack versions for UI (jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk 1667fbf99 -> 77b301688


AMBARI-12746: [PluggableStackDefinition] Generate UI mapping for stack versions for UI (jluniya)


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

Branch: refs/heads/trunk
Commit: 77b3016884ae87c57de07c58997da1e2cebea237
Parents: 1667fbf
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Wed Aug 12 10:02:07 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Wed Aug 12 10:02:07 2015 -0700

----------------------------------------------------------------------
 .../GenerateStackDefinition.py                  | 25 ++++++++++++++++++++
 .../python/pluggable_stack_definition/test.json |  7 ++++++
 ambari-server/pom.xml                           | 18 ++++++++++++++
 3 files changed, 50 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/77b30168/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py b/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
index b95a937..b867ed7 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
+++ b/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
@@ -30,6 +30,11 @@ from os.path import join
 import random
 import string
 
+UI_MAPPING_TEMPLATE = """var App = require('app');
+module.exports = {0};
+"""
+UI_MAPPING_MAP = {"2.2":"HDP2.2",
+                  "2.3":"HDP2.3"}
 
 def generate_random_string(size=7, chars=string.ascii_uppercase + string.digits):
   return ''.join(random.choice(chars) for _ in range(size))
@@ -359,6 +364,8 @@ def process_py_files(file_path, config_data, stack_version_changes):
 def process_xml_files(file_path, config_data, stack_version_changes):
   return process_replacements(file_path, config_data, stack_version_changes)
 
+
+
 class GeneratorHelper(object):
   def __init__(self, config_data, resources_folder, output_folder):
     self.config_data = config_data
@@ -469,6 +476,23 @@ class GeneratorHelper(object):
 
     copy_tree(source_folder, target_folder, ignored_files, post_copy=post_copy)
 
+  def generate_ui_mapping(self):
+    stack_name = self.config_data.stackName
+    records = []
+    for _from, _to in self.stack_version_changes.iteritems():
+      base_stack_folder = UI_MAPPING_MAP[_from] if _from in UI_MAPPING_MAP else "HDP2"
+      record = {"stackName": stack_name,
+                "stackVersionNumber": _to,
+                "sign": "=",
+                "baseStackFolder": base_stack_folder}
+      records.append(record)
+    if "uiMapping" in self.config_data:
+      for mapping in self.config_data.uiMapping:
+        mapping["stackName"] = stack_name
+        records.append(mapping)
+    js_file_content = UI_MAPPING_TEMPLATE.format(json.dumps(records, indent=2))
+    open(os.path.join(self.output_folder, "custom_stack_map.js"),"w").write(js_file_content)
+    pass
 
 def main(argv):
   HELP_STRING = 'GenerateStackDefinition.py -c <config> -r <resources_folder> -o <output_folder>'
@@ -499,6 +523,7 @@ def main(argv):
   gen_helper.copy_stacks()
   gen_helper.copy_resource_management()
   gen_helper.copy_common_services()
+  gen_helper.generate_ui_mapping()
 
 
 if __name__ == "__main__":

http://git-wip-us.apache.org/repos/asf/ambari/blob/77b30168/ambari-common/src/main/python/pluggable_stack_definition/test.json
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/pluggable_stack_definition/test.json b/ambari-common/src/main/python/pluggable_stack_definition/test.json
index 729cc63..92da79e 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/test.json
+++ b/ambari-common/src/main/python/pluggable_stack_definition/test.json
@@ -7,6 +7,13 @@
     ["conf-select", "phd-conf-select"]
    ],
   "preservedText": ["ext-2.2", "HDP-oozie", "hdp.version", "HDP_VERSION"],
+  "uiMapping": [
+    {
+      "stackVersionNumber": "3.0",
+      "sign": "<",
+      "baseStackFolder": "HDP2"
+    }
+  ],
   "versions": [
     {
       "version": "2.0.6",

http://git-wip-us.apache.org/repos/asf/ambari/blob/77b30168/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 74d1837..48337ea 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -41,6 +41,7 @@
     <ambari-admin-dir>${basedir}/../ambari-admin</ambari-admin-dir>
     <contrib-views-dir>${basedir}/../contrib/views</contrib-views-dir>
     <resourceManagementSrcLocation>${project.basedir}/../ambari-common/src/main/python/resource_management</resourceManagementSrcLocation>
+    <customStackMap>${basedir}/../ambari-web/app/data/custom_stack_map.js</customStackMap>
     <commonServicesSrcLocation>target/classes/common-services</commonServicesSrcLocation>
     <stacksSrcLocation>target/classes/stacks/${stack.distribution}</stacksSrcLocation>
     <tarballResourcesFolder>src/main/resources</tarballResourcesFolder>
@@ -294,6 +295,14 @@
               </dependency>
             </mapping>
             <mapping>
+              <directory>/usr/lib/ambari-server/app/data</directory>
+              <sources>
+                <source>
+                  <location>${customStackMap}</location>
+                </source>
+              </sources>
+            </mapping>
+            <mapping>
               <directory>/usr/lib/ambari-server/web</directory>
               <sources>
                 <source>
@@ -1082,6 +1091,14 @@
               </mapper>
             </data>
             <data>
+              <src>${customStackMap}</src>
+              <type>file</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>/usr/lib/ambari-server/app/data</prefix>
+              </mapper>
+            </data>
+            <data>
               <src>src/main/python/os_check_type.py</src>
               <type>file</type>
               <mapper>
@@ -1519,6 +1536,7 @@
         </property>
       </activation>
       <properties>
+        <customStackMap>target/pluggable-stack-definition/custom_stack_map.js</customStackMap>
         <resourceManagementSrcLocation>target/pluggable-stack-definition/python/resource_management</resourceManagementSrcLocation>
         <commonServicesSrcLocation>target/pluggable-stack-definition/common-services</commonServicesSrcLocation>
         <stacksSrcLocation>target/pluggable-stack-definition/stacks/${stack.distribution}</stacksSrcLocation>