ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-12816: [PluggableStackDefinition] add processing of custom actions (Eugene Chekanskiy via jluniya)
Date Wed, 19 Aug 2015 20:21:33 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk ba7a94fde -> bcbb0ae41


AMBARI-12816: [PluggableStackDefinition] add processing of custom actions (Eugene Chekanskiy
via jluniya)


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

Branch: refs/heads/trunk
Commit: bcbb0ae41e98b9e9c4e1d91383b900525633becb
Parents: ba7a94f
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Wed Aug 19 13:21:27 2015 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Wed Aug 19 13:21:27 2015 -0700

----------------------------------------------------------------------
 ambari-agent/pom.xml                            | 28 ++++++++++++++
 .../GenerateStackDefinition.py                  | 39 +++++++++++++++-----
 .../pluggable_stack_definition/configs/PHD.json | 12 ++++++
 ambari-server/pom.xml                           |  6 ++-
 4 files changed, 73 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bcbb0ae4/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index 6ed8bff..24927e2 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -53,6 +53,7 @@
     <init.d.dir>/etc/rc.d/init.d</init.d.dir>
     <resourceManagementSrcLocation>${project.basedir}/../ambari-common/src/main/python/resource_management</resourceManagementSrcLocation>
     <resourcesFolder>${ambari.server.module}/src/main/resources</resourcesFolder>
+    <customActionsLocation>${target.cache.dir}/custom_actions</customActionsLocation>
   </properties>
   <build>
     <plugins>
@@ -438,6 +439,20 @@
               <sources>
                 <source>
                   <location>${target.cache.dir}</location>
+                  <excludes>
+                    <exclude>custom_actions/scripts/*</exclude>
+                  </excludes>
+                </source>
+              </sources>
+            </mapping>
+            <mapping>
+              <directory>/var/lib/ambari-agent/cache/custom_actions</directory>
+              <filemode>755</filemode>
+              <username>root</username>
+              <groupname>root</groupname>
+              <sources>
+                <source>
+                  <location>${customActionsLocation}</location>
                 </source>
               </sources>
             </mapping>
@@ -640,6 +655,7 @@
             <data>
               <src>${target.cache.dir}</src>
               <type>directory</type>
+              <excludes>custom_actions/scripts/*</excludes>
               <mapper>
                 <type>perm</type>
                 <prefix>/var/lib/ambari-agent/cache</prefix>
@@ -649,6 +665,17 @@
               </mapper>
             </data>
             <data>
+              <src>${customActionsLocation}</src>
+              <type>directory</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>/var/lib/ambari-agent/cache/custom_actions</prefix>
+                <user>root</user>
+                <group>root</group>
+                <filemode>755</filemode>
+              </mapper>
+            </data>
+            <data>
               <src>
                 ${project.basedir}/../ambari-common/src/main/python/ambari_commons
               </src>
@@ -934,6 +961,7 @@
         <pluggableStackDefinitionScriptLocation>${project.basedir}/../ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py</pluggableStackDefinitionScriptLocation>
         <pluggableStackDefinitionConfig>${project.basedir}/../ambari-common/src/main/python/pluggable_stack_definition/configs/${stack.distribution}.json</pluggableStackDefinitionConfig>
         <pluggableStackDefinitionOutput>target/pluggable-stack-definition</pluggableStackDefinitionOutput>
+        <customActionsLocation>${pluggableStackDefinitionOutput}/custom_actions</customActionsLocation>
       </properties>
       <build>
         <plugins>

http://git-wip-us.apache.org/repos/asf/ambari/blob/bcbb0ae4/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 2ba6f77..c09c788 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
+++ b/ambari-common/src/main/python/pluggable_stack_definition/GenerateStackDefinition.py
@@ -125,6 +125,7 @@ def process_replacements(file_path, config_data, stack_version_changes):
   if not file_path.endswith(".xml"):
     for _from, _to in stack_version_changes.iteritems():
       file_data = file_data.replace(_from, _to)
+      file_data = process_version_replace(file_data, _from, _to)
   # preform common replacements
   if 'performCommonReplacements' in config_data and config_data.performCommonReplacements:
     for from_version, to_version in stack_version_changes.iteritems():
@@ -139,6 +140,18 @@ def process_replacements(file_path, config_data, stack_version_changes):
     target.write(file_data.encode('utf-8'))
   return file_path
 
+def process_version_replace(text, base_version, version):
+  dash_base_version = base_version.replace('.', '-')
+  dash_version = version.replace('.', '-')
+  underscore_base_version = base_version.replace('.', '_')
+  underscore_version = version.replace('.', '_')
+  if dash_base_version in text:
+    text = text.replace(dash_base_version, dash_version)
+  if underscore_base_version in text:
+    text = text.replace(underscore_base_version, underscore_version)
+  return text
+
+
 def process_metainfo(file_path, config_data, stack_version_changes, common_services = []):
   tree = ET.parse(file_path)
   root = tree.getroot()
@@ -247,16 +260,7 @@ def process_metainfo(file_path, config_data, stack_version_changes, common_servi
                       name_tag = package_tag.find('name')
                       for base_version in stack_version_changes:
                         version = stack_version_changes[base_version]
-                        dash_base_version = base_version.replace('.', '-')
-                        dash_version = version.replace('.', '-')
-                        underscore_base_version = base_version.replace('.', '_')
-                        underscore_version = version.replace('.', '_')
-                        if dash_base_version in name_tag.text:
-                          name_tag.text = name_tag.text.replace(dash_base_version, dash_version)
-                          break
-                        elif underscore_base_version in name_tag.text:
-                          name_tag.text = name_tag.text.replace(underscore_base_version,
underscore_version)
-                          break
+                        name_tag.text = process_version_replace(name_tag.text, base_version,
version)
     tree.write(file_path)
   return file_path
 
@@ -520,6 +524,20 @@ class GeneratorHelper(object):
     open(os.path.join(self.output_folder, "custom_stack_map.js"),"w").write(js_file_content)
     pass
 
+  def copy_custom_actions(self):
+    original_folder = os.path.join(self.resources_folder, 'custom_actions')
+    target_folder = os.path.join(self.output_folder, 'custom_actions')
+    ignored_files = ['.pyc']
+
+    def post_copy(src, target):
+      # process python files
+      if target.endswith('.py'):
+        # process script.py
+        process_py_files(target, self.config_data, self.stack_version_changes)
+        return
+
+    copy_tree(original_folder, target_folder, ignored_files, post_copy=post_copy)
+
 def main(argv):
   HELP_STRING = 'GenerateStackDefinition.py -c <config> -r <resources_folder>
-o <output_folder>'
   config = ''
@@ -551,6 +569,7 @@ def main(argv):
   gen_helper.copy_common_services()
   gen_helper.copy_ambari_properties()
   gen_helper.generate_ui_mapping()
+  gen_helper.copy_custom_actions()
 
 
 if __name__ == "__main__":

http://git-wip-us.apache.org/repos/asf/ambari/blob/bcbb0ae4/ambari-common/src/main/python/pluggable_stack_definition/configs/PHD.json
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/pluggable_stack_definition/configs/PHD.json b/ambari-common/src/main/python/pluggable_stack_definition/configs/PHD.json
index 5c96bd6..88ce152 100644
--- a/ambari-common/src/main/python/pluggable_stack_definition/configs/PHD.json
+++ b/ambari-common/src/main/python/pluggable_stack_definition/configs/PHD.json
@@ -29,6 +29,9 @@
       "active": "false",
       "services": [
         {
+          "name": "AMBARI_METRICS"
+        },
+        {
           "name": "HDFS"
 
         },
@@ -68,6 +71,9 @@
       "family": "redhat6,suse11",
       "services": [
         {
+          "name": "AMBARI_METRICS"
+        },
+        {
           "name": "HDFS"
         },
         {
@@ -106,6 +112,9 @@
       "family": "redhat6,suse11",
       "services": [
         {
+          "name": "AMBARI_METRICS"
+        },
+        {
           "name": "HDFS"
         },
         {
@@ -175,6 +184,9 @@
       "family": "redhat6,redhat7,suse11",
       "services": [
         {
+          "name": "AMBARI_METRICS"
+        },
+        {
           "name": "HDFS"
         },
         {

http://git-wip-us.apache.org/repos/asf/ambari/blob/bcbb0ae4/ambari-server/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-server/pom.xml b/ambari-server/pom.xml
index 7d09cc1..2e16a59 100644
--- a/ambari-server/pom.xml
+++ b/ambari-server/pom.xml
@@ -42,6 +42,7 @@
     <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>
+    <customActionsRoot>src/main/resources/custom_actions</customActionsRoot>
     <ambariProperties>conf/unix/ambari.properties</ambariProperties>
     <commonServicesSrcLocation>target/classes/common-services</commonServicesSrcLocation>
     <stacksSrcLocation>target/classes/stacks/${stack.distribution}</stacksSrcLocation>
@@ -668,7 +669,7 @@
               <groupname>root</groupname>
               <sources>
                 <source>
-                  <location>src/main/resources/custom_actions</location>
+                  <location>${customActionsRoot}</location>
                 </source>
               </sources>
             </mapping>
@@ -1127,7 +1128,7 @@
               </mapper>
             </data>
             <data>
-              <src>src/main/resources/custom_actions</src>
+              <src>${customActionsRoot}</src>
               <type>directory</type>
               <mapper>
                 <type>perm</type>
@@ -1537,6 +1538,7 @@
         </property>
       </activation>
       <properties>
+        <customActionsRoot>target/pluggable-stack-definition/custom_actions</customActionsRoot>
         <customStackMap>target/pluggable-stack-definition/custom_stack_map.js</customStackMap>
         <ambariProperties>target/pluggable-stack-definition/conf/unix/ambari.properties</ambariProperties>
         <resourceManagementSrcLocation>target/pluggable-stack-definition/python/resource_management</resourceManagementSrcLocation>


Mime
View raw message