incubator-ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] git commit: AMBARI-2987. custom JDK path is not trimmed causing ulcers for puppet (Dmytro Shkvyra via dlysnichenko)
Date Thu, 22 Aug 2013 15:01:12 GMT
AMBARI-2987. custom JDK path is not trimmed causing ulcers for puppet (Dmytro Shkvyra via dlysnichenko)


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

Branch: refs/heads/trunk
Commit: 758bbc1ac6196eb24c21ed34485e96e414a260ae
Parents: 8d46a38
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Aug 22 18:00:12 2013 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Aug 22 18:00:12 2013 +0300

----------------------------------------------------------------------
 .../modules/hdp/lib/puppet/parser/functions/hdp_default.rb    | 5 ++++-
 .../hdp/lib/puppet/parser/functions/hdp_template_var.rb       | 3 +++
 ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py   | 7 ++++---
 ambari-agent/src/main/python/ambari_agent/test.json           | 3 ++-
 ambari-agent/src/test/python/TestPuppetExecutor.py            | 2 ++
 5 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/758bbc1a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_default.rb
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_default.rb
b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_default.rb
index 999bf71..7d48cab 100644
--- a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_default.rb
+++ b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_default.rb
@@ -25,7 +25,10 @@ module Puppet::Parser::Functions
     var_parts = scoped_var_name.split("/")
     var_name = var_parts.last    
     default = args[1]    
-    val = lookupvar("::#{var_name}")    
+    val = lookupvar("::#{var_name}") 
+    if function_hdp_is_empty(val) == false and val.class == String
+      val = val.strip
+    end      
     # Lookup value inside a hash map.
     if var_parts.length > 1 and function_hdp_is_empty(val) and function_hdp_is_empty(lookupvar("::configuration"))
== false and function_hdp_is_empty(lookupvar("#{var_parts[-2]}")) == false
       keyHash = var_parts[-2]

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/758bbc1a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_template_var.rb
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_template_var.rb
b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_template_var.rb
index 52ab7c9..78a84a5 100644
--- a/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_template_var.rb
+++ b/ambari-agent/src/main/puppet/modules/hdp/lib/puppet/parser/functions/hdp_template_var.rb
@@ -30,6 +30,9 @@ module Puppet::Parser::Functions
       qualified_var = "#{module_name}::params::#{args[0]}"
     end
     val = lookupvar(qualified_var)
+    if function_hdp_is_empty(val) == false and val.class == String
+      val = val.strip
+    end  
     (val.nil? or val == :undefined) ? "" : val 
   end
 end

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/758bbc1a/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py b/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
index 4769b07..eb74472 100644
--- a/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/PuppetExecutor.py
@@ -148,13 +148,14 @@ class PuppetExecutor:
     return result
   
   def isJavaAvailable(self, command):
-    javaExecutablePath = "{0}/bin/java".format(command['configurations']['global']['java64_home'])
+    javaExecutablePath = "{0}/bin/java".format(command)
     return not self.sh.run([javaExecutablePath, '-version'])['exitCode']
     
   def runCommand(self, command, tmpoutfile, tmperrfile):
     # After installing we must have jdk available for start/stop/smoke
-    if command['roleCommand']!="INSTALL" and not self.isJavaAvailable(command):
-      errMsg = JAVANOTVALID_MSG.format(command['configurations']['global']['java64_home'])
+    java64_home = str(command['configurations']['global']['java64_home']).strip()
+    if command['roleCommand']!="INSTALL" and not self.isJavaAvailable(java64_home):
+      errMsg = JAVANOTVALID_MSG.format(java64_home)
       return {'stdout': '', 'stderr': errMsg, 'exitcode': 1}
 
     taskId = 0

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/758bbc1a/ambari-agent/src/main/python/ambari_agent/test.json
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/test.json b/ambari-agent/src/main/python/ambari_agent/test.json
index 066d3ee..d175ae1 100644
--- a/ambari-agent/src/main/python/ambari_agent/test.json
+++ b/ambari-agent/src/main/python/ambari_agent/test.json
@@ -53,7 +53,8 @@
 "hadoop_metrics" : {"ganglia_server_host" : "localhost"},
 "hive-site" : {"hive.exec.scratchdir" : "/tmp"},
 "oozie-site" : {"oozie.service.ActionService.executor.ext.classes" : "org.apache.oozie.action.hadoop.HiveActionExecutor,
org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.email.EmailActionExecutor,"},
-"templeton-site" : {"templeton.override.enabled" : "true"}
+"templeton-site" : {"templeton.override.enabled" : "true"},
+"global" : {"java64_home" : " java64_home "}
 },
 
 "role": "NAMENODE",

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/758bbc1a/ambari-agent/src/test/python/TestPuppetExecutor.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/TestPuppetExecutor.py b/ambari-agent/src/test/python/TestPuppetExecutor.py
index 85e480e..dc60e84 100644
--- a/ambari-agent/src/test/python/TestPuppetExecutor.py
+++ b/ambari-agent/src/test/python/TestPuppetExecutor.py
@@ -109,6 +109,7 @@ class TestPuppetExecutor(TestCase):
     jsonStr = jsonFile.read()
     parsedJson = json.loads(jsonStr)
     parsedJson["taskId"] = 77
+    parsedJson['roleCommand'] = "START"
     def side_effect(puppetFile, result, puppetEnv, tmpoutfile, tmperrfile):
       result["exitcode"] = 0
     runPuppetFileMock.side_effect = side_effect
@@ -126,6 +127,7 @@ class TestPuppetExecutor(TestCase):
     puppetInstance.runCommand(parsedJson, tmpdir + '/out.txt', tmpdir + '/err.txt')
     self.assertTrue(puppetInstance.reposInstalled)
     self.assertEquals(1, generateRepoManifestMock.call_count)
+    isJavaAvailableMock.assert_called_with("java64_home")
 
     # After executing of the next commands, repo manifest aren't generated again
     puppetInstance.runCommand(parsedJson, tmpdir + '/out.txt', tmpdir + '/err.txt')


Mime
View raw message