You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by om...@apache.org on 2011/12/02 00:46:50 UTC

svn commit: r1209312 - in /incubator/ambari/trunk: CHANGES.txt agent/src/main/python/ambari_agent/FileUtil.py

Author: omalley
Date: Thu Dec  1 23:46:49 2011
New Revision: 1209312

URL: http://svn.apache.org/viewvc?rev=1209312&view=rev
Log:
AMBARI-146. Fix test case failures in agent's FileUtil. (omalley)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1209312&r1=1209311&r2=1209312&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Thu Dec  1 23:46:49 2011
@@ -2,11 +2,15 @@ Ambari Change log
 
 Release 0.1.0 - unreleased
 
-  AMBARI-144. Implement getInstallAndConfigureScript for a given revision of cluster definition. (vgogate)
+  AMBARI-146. Fix test case failures in agent's FileUtil. (omalley)
+
+  AMBARI-144. Implement getInstallAndConfigureScript for a given
+  revision of cluster definition. (vgogate)
 
   AMBARI-143. Fixes an annotation issue in HeartBeat class (ddas)
 
-  AMBZRI-142. Add cluster must validate if requested nodes are pre-allocated to any other existing cluster (vgogate)
+  AMBZRI-142. Add cluster must validate if requested nodes are
+  pre-allocated to any other existing cluster (vgogate)
 
   AMBARI-140. Refactors the heartbeat handling w.r.t simplification of 
   state management. (ddas)

Modified: incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py?rev=1209312&r1=1209311&r2=1209312&view=diff
==============================================================================
--- incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py (original)
+++ incubator/ambari/trunk/agent/src/main/python/ambari_agent/FileUtil.py Thu Dec  1 23:46:49 2011
@@ -33,22 +33,19 @@ import AmbariConfig
 logger = logging.getLogger()
 
 def writeFile(action, result):
-  oldCwd = os.getcwd()
   fileInfo = action['file']
   try:
-    if fileInfo['path'].startswith('/'):
-      path = fileInfo['path']
-    else:
-      path = AmbariConfig.config.get('agent','prefix')+"/clusters/"+action['clusterId']+"-"+action['role']
+    path = os.path.join(AmbariConfig.config.get('agent','prefix'),
+                        "clusters", 
+                        action['clusterId']+"-"+action['role'])
     logger.info("path: %s" % path)
-    os.chdir(path)
     user=fileInfo['owner']
     if user is None:
       user=getpass.getuser()
     group=fileInfo['group']
     if group is None:
       group=getpass.getgroup()
-    filename=fileInfo['path']
+    filename=os.path.join(path, fileInfo['path'])
     content=fileInfo['data']
     try:
       if isinstance(user, int)!=True:
@@ -58,7 +55,7 @@ def writeFile(action, result):
     except Exception:
       logger.warn("can not find user uid/gid: (%s/%s) for writing %s" % (user, group, filename))
     if fileInfo['permission'] is not None:
-      permission=int(fileInfo['permission'],8)
+      permission=fileInfo['permission']
     else:
       permission=0750
     oldMask = os.umask(0)
@@ -84,15 +81,16 @@ def writeFile(action, result):
     os.umask(oldMask)
     result['exitCode'] = 0
   except Exception, err:
+    traceback.print_exc()
     result['exitCode'] = 1
     result['stderr'] = traceback.format_exc()
-  os.chdir(oldCwd)
   return result
 
 def createStructure(action, result):
   try:
     workdir = action['workDirComponent']
     path = AmbariConfig.config.get('agent','prefix')+"/clusters/"+workdir
+    shutil.rmtree(path, 1)
     os.makedirs(path+"/stack")
     os.makedirs(path+"/logs")
     os.makedirs(path+"/data")
@@ -100,6 +98,7 @@ def createStructure(action, result):
     os.makedirs(path+"/config")
     result['exitCode'] = 0
   except Exception, err:
+    traceback.print_exc()
     result['exitCode'] = 1
     result['stderr'] = traceback.format_exc()
   return result