You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dd...@apache.org on 2011/12/17 02:54:44 UTC
svn commit: r1215385 - in
/incubator/ambari/trunk/agent/src/main/python/ambari_agent: ActionQueue.py
AmbariConfig.py ServerStatus.py shell.py
Author: ddas
Date: Sat Dec 17 01:54:43 2011
New Revision: 1215385
URL: http://svn.apache.org/viewvc?rev=1215385&view=rev
Log:
AMBARI-157. After some integration tests.
Modified:
incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py
incubator/ambari/trunk/agent/src/main/python/ambari_agent/AmbariConfig.py
incubator/ambari/trunk/agent/src/main/python/ambari_agent/ServerStatus.py
incubator/ambari/trunk/agent/src/main/python/ambari_agent/shell.py
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py?rev=1215385&r1=1215384&r2=1215385&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/ActionQueue.py Sat Dec 17 01:54:43 2011
@@ -122,6 +122,7 @@ class ActionQueue(threading.Thread):
if (action['kind'] == 'INSTALL_AND_CONFIG_ACTION' or action['kind'] == 'NO_OP_ACTION'):
result = {
'id' : action['id'],
+ 'kind' : action['kind'],
}
else:
result = {
@@ -129,7 +130,7 @@ class ActionQueue(threading.Thread):
'clusterId' : action['clusterId'],
'kind' : action['kind'],
'clusterDefinitionRevision' : action['clusterDefinitionRevision'],
- 'component' : action['component'],
+ 'componentName' : action['component'],
'role' : action['role']
}
return result
@@ -138,8 +139,7 @@ class ActionQueue(threading.Thread):
# track the liveness of the children process
def startAction(self, action):
result = self.genResult(action)
- return self.sh.startProcess(action['workDirComponent'],
- action['clusterId'],
+ return self.sh.startProcess(action['clusterId'],
action['clusterDefinitionRevision'],
action['component'],
action['role'],
@@ -195,8 +195,7 @@ class ActionQueue(threading.Thread):
# Run command action
def runAction(self, action):
result = self.genResult(action)
- return self.sh.runAction(action['workDirComponent'],
- action['clusterId'],
+ return self.sh.runAction(action['clusterId'],
action['component'],
action['role'],
action['user'],
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/AmbariConfig.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/AmbariConfig.py?rev=1215385&r1=1215384&r2=1215385&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/AmbariConfig.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/AmbariConfig.py Sat Dec 17 01:54:43 2011
@@ -33,6 +33,9 @@ password=controller
[agent]
prefix=/tmp/ambari
+[stack]
+installprefix=/var/ambari
+
[puppet]
prefix=/homes/ddas/puppet
commandpath=/usr/local/bin/puppet apply --modulepath /home/puppet/puppet-ambari/modules
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/ServerStatus.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/ServerStatus.py?rev=1215385&r1=1215384&r2=1215385&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/ServerStatus.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/ServerStatus.py Sat Dec 17 01:54:43 2011
@@ -35,7 +35,7 @@ class ServerStatus:
result = {
'clusterId' : clusterId,
'clusterDefinitionRevision' : clusterDefinitionRevision,
- 'component' : component,
+ 'componentName' : component,
'roleName' : role,
'serverStatus' : 'STARTED'
}
Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/shell.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/shell.py?rev=1215385&r1=1215384&r2=1215385&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/shell.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/shell.py Sat Dec 17 01:54:43 2011
@@ -20,6 +20,7 @@ limitations under the License.
from pwd import getpwnam
from grp import getgrnam
+import AmbariConfig
import logging
import logging.handlers
import subprocess
@@ -56,9 +57,9 @@ class shellRunner:
return {'exitCode': code, 'output': out, 'error': err}
# dispatch action types
- def runAction(self, workdir, clusterId, component, role, user, command, cleanUpCommand, result):
+ def runAction(self, clusterId, component, role, user, command, cleanUpCommand, result):
oldDir = os.getcwd()
- os.chdir(workdir)
+ os.chdir(self.getWorkDir(clusterId, role))
oldUid = os.getuid()
try:
if user is not None:
@@ -109,10 +110,10 @@ class shellRunner:
return result
# Start a process and presist its state
- def startProcess(self, workdir, clusterId, clusterDefinitionRevision, component, role, script, user, result):
+ def startProcess(self, clusterId, clusterDefinitionRevision, component, role, script, user, result):
global serverTracker
oldDir = os.getcwd()
- os.chdir(workdir)
+ os.chdir(self.getWorkDir(clusterId,role))
oldUid = os.getuid()
try:
user=getpwnam(user)[2]
@@ -160,4 +161,8 @@ class shellRunner:
return serverTracker
def getServerKey(self,clusterId, clusterDefinitionRevision, component, role):
- return clusterId+"/"+clusterDefinitionRevision+"/"+component+"/"+role
+ return clusterId+"/"+str(clusterDefinitionRevision)+"/"+component+"/"+role
+
+ def getWorkDir(self, clusterId, role):
+ prefix = AmbariConfig.config.get('stack','installprefix')
+ return str(os.path.join(prefix, clusterId, role))