summaryrefslogtreecommitdiff
path: root/ambari-agent
diff options
context:
space:
mode:
authorMahadev Konar <mahadev@apache.org>2012-10-24 06:46:38 +0000
committerMahadev Konar <mahadev@apache.org>2012-10-24 06:46:38 +0000
commitf3bdc22a38842c818b4cedebdf8d06ffb6503170 (patch)
tree95a2ea9d480fc96120351840dfc2654f77678837 /ambari-agent
parent76849482eef70ae3180deee2707d6cdfd1789414 (diff)
AMBARI-905. Fix puppet site creation with flattening of execution commands send from the server. (mahadev)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1401568 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ambari-agent')
-rw-r--r--ambari-agent/src/main/python/ambari_agent/ActionQueue.py6
-rw-r--r--ambari-agent/src/main/python/ambari_agent/AmbariConfig.py2
-rw-r--r--ambari-agent/src/main/python/ambari_agent/manifestGenerator.py16
-rw-r--r--ambari-agent/src/main/python/ambari_agent/puppetExecutor.py4
-rw-r--r--ambari-agent/src/main/python/ambari_agent/site.pp33
-rw-r--r--ambari-agent/src/main/python/ambari_agent/test.json51
6 files changed, 38 insertions, 74 deletions
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index 0936ca222b..5b567701d1 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -119,6 +119,10 @@ class ActionQueue(threading.Thread):
configurations = command['configurations']
result = []
commandresult = self.executor.runCommand(command)
+ status = "COMPLETED"
+ if (commandresult['exitcode'] != 0):
+ status = "FAILED"
+
# assume some puppet pluing to run these commands
roleResult = {'role' : command['role'],
'actionId' : commandId,
@@ -127,7 +131,7 @@ class ActionQueue(threading.Thread):
'stderr' : commandresult['stderr'],
'exitCode' : commandresult['exitcode'],
'serviceName' : serviceName,
- 'status' : "COMPLETED"}
+ 'status' : status}
result.append(roleResult)
pass
return result
diff --git a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
index 9648aa8c91..a1250d6e00 100644
--- a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
+++ b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
@@ -31,7 +31,7 @@ url=https://localhost:4080
secured_url=https://localhost:8443
[agent]
-prefix=/tmp/ambari
+prefix=/tmp/ambari-agent
[stack]
installprefix=/var/ambari/
diff --git a/ambari-agent/src/main/python/ambari_agent/manifestGenerator.py b/ambari-agent/src/main/python/ambari_agent/manifestGenerator.py
index cdb18b0eea..b2e96e0c1e 100644
--- a/ambari-agent/src/main/python/ambari_agent/manifestGenerator.py
+++ b/ambari-agent/src/main/python/ambari_agent/manifestGenerator.py
@@ -24,6 +24,13 @@ import logging
logger = logging.getLogger()
+xml_configurations_keys= ["hdfs_site", "hdfs_site", "core_site",
+ "mapred_queue_acls",
+ "hadoop_policy", "mapred_site",
+ "capacity_scheduler", "hbase_site",
+ "hbase_policy", "hive_site", "oozie_site",
+ "templeton_site"]
+
#read static imports from file and write them to manifest
def writeImports(outputFile, modulesdir, inputFileName='imports.txt'):
inputFile = open(inputFileName, 'r')
@@ -39,12 +46,13 @@ def generateManifest(parsedJson, fileName, modulesdir):
#reading json
hostname = parsedJson['hostname']
clusterHostInfo = parsedJson['clusterHostInfo']
- params = parsedJson['params']
+ params = parsedJson['hostLevelParams']
configurations = parsedJson['configurations']
- xmlConfigurationsKeys = parsedJson['xml_configurations_keys']
+ xmlConfigurationsKeys = xml_configurations_keys
#hostAttributes = parsedJson['hostAttributes']
- roles = parsedJson['roleCommands']
-
+ roles = [{'role' : parsedJson['role'],
+ 'cmd' : parsedJson['roleCommand'],
+ 'roleParams' : parsedJson['roleParams']}]
#writing manifest
manifest = open(fileName, 'w')
diff --git a/ambari-agent/src/main/python/ambari_agent/puppetExecutor.py b/ambari-agent/src/main/python/ambari_agent/puppetExecutor.py
index 16cfbd0c57..0333c02adc 100644
--- a/ambari-agent/src/main/python/ambari_agent/puppetExecutor.py
+++ b/ambari-agent/src/main/python/ambari_agent/puppetExecutor.py
@@ -59,12 +59,12 @@ class puppetExecutor:
def runCommand(self, command):
result = {}
- taskId = "0";
+ taskId = 0;
if command.has_key("taskId"):
taskId = command['taskId']
puppetEnv = os.environ
- siteppFileName = os.path.join(self.tmpDir, "site-" + taskId + ".pp")
+ siteppFileName = os.path.join(self.tmpDir, "site-" + str(taskId) + ".pp")
generateManifest(command, siteppFileName, self.puppetModule + "/modules")
puppetcommand = self.puppetCommand(siteppFileName)
""" Run the command and make sure the output gets propagated"""
diff --git a/ambari-agent/src/main/python/ambari_agent/site.pp b/ambari-agent/src/main/python/ambari_agent/site.pp
index dddca5358c..3b8f9465b2 100644
--- a/ambari-agent/src/main/python/ambari_agent/site.pp
+++ b/ambari-agent/src/main/python/ambari_agent/site.pp
@@ -1,15 +1,15 @@
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-hbase/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-zookeeper/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-pig/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-sqoop/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-hcat/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/*.pp'
-import '/home/centos/ambari/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-hadoop/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-hbase/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-zookeeper/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-oozie/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-pig/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-sqoop/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-templeton/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-hive/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-hcat/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-mysql/manifests/*.pp'
+import '/media/sf_/home/mahadev/workspace/ambari-workspace/ambari-git/ambari-agent/src/main/puppet/modules/hdp-monitor-webserver/manifests/*.pp'
$NAMENODE= ['h2.hortonworks.com']
$DATANODE= ['h1.hortonworks.com', 'h2.hortonworks.com']
$hdfs_user="hdfs"
@@ -66,13 +66,6 @@ $task_bin_exe = "ls"
$hadoop_piddirprefix = "/tmp"
$ganglia_server_host = "localhost"
node /default/ {
- stage{1 :} -> stage{2 :} -> stage{3 :} -> stage{4 :} -> stage{5 :} -> stage{6 :} -> stage{7 :} -> stage{8 :}
+ stage{1 :}
class {'hdp-hadoop::namenode': stage => 1, service_state => installed_and_configured}
-class {'hdp-hadoop::datanode': stage => 2, service_state => installed_and_configured}
-class {'hdp-hbase::master': stage => 3, service_state => installed_and_configured}
-class {'hdp-hive::server': stage => 4, service_state => installed_and_configured}
-class {'hdp-hive::client': stage => 5, service_state => installed_and_configured}
-class {'hdp-oozie::server': stage => 6, service_state => installed_and_configured}
-class {'hdp-templeton::server': stage => 7, service_state => installed_and_configured}
-class {'hdp-templeton::client': stage => 8, service_state => installed_and_configured}
}
diff --git a/ambari-agent/src/main/python/ambari_agent/test.json b/ambari-agent/src/main/python/ambari_agent/test.json
index 6bc49ac5a4..42339adc8e 100644
--- a/ambari-agent/src/main/python/ambari_agent/test.json
+++ b/ambari-agent/src/main/python/ambari_agent/test.json
@@ -7,7 +7,7 @@
"NAMENODE": ["h2.hortonworks.com"],
"DATANODE": ["h1.hortonworks.com", "h2.hortonworks.com"]
},
-"params":
+"hostLevelParams":
{
"hdfs_user" : "hdfs",
"jdk_location" : "http://hdp1/downloads",
@@ -17,9 +17,6 @@
"jdk_bins" : { "32" : "jdk-6u31-linux-x64.bin", "64" : "jdk-6u31-linux-x64.bin" }
},
-"xml_configurations_keys" : ["hdfs_site", "hdfs_site", "core_site", "mapred_queue_acls",
- "hadoop_policy", "mapred_site", "capacity_scheduler", "hbase_site",
- "hbase_policy", "hive_site", "oozie_site", "templeton_site"],
"configurations" : {
"hdfs_site" : { "dfs.block.size" : "256000000", "dfs.replication" : "1" } ,
@@ -43,46 +40,8 @@
"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"}
},
-"roleCommands": [
-{
- "role": "NAMENODE",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "DATANODE",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "HBASE_MASTER",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "HIVE_SERVER",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "HIVE_CLIENT",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "OOZIE_SERVER",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "TEMPLETON_SERVER",
- "cmd": "INSTALL",
- "roleParams" : {}
-},
-{
- "role": "TEMPLETON_CLIENT",
- "cmd": "INSTALL",
- "roleParams" : {}
-}
-]
+
+"role": "NAMENODE",
+"roleCommand": "INSTALL",
+"roleParams" : {}
}