You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/06/13 05:37:36 UTC

svn commit: r1492522 - in /incubator/ambari/trunk/ambari-server/src/main/python: ambari-server.py bootstrap.py

Author: mahadev
Date: Thu Jun 13 03:37:35 2013
New Revision: 1492522

URL: http://svn.apache.org/r1492522
Log:
AMBARI-2374. The installation under sudo user is failing during rerun under the same sudo user. (Oleksandr via mahadev)

Modified:
    incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
    incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py

Modified: incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py?rev=1492522&r1=1492521&r2=1492522&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py Thu Jun 13 03:37:35 2013
@@ -756,7 +756,7 @@ def check_postgre_up():
     print_info_msg ("PostgreSQL is running")
     return 0
   else:
-    print "Run initdb"
+    print "Running initdb: This may take upto a minute."
     retcode, out, err = run_os_command(PG_INITDB_CMD)
     if retcode == 0:
       print out

Modified: incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py?rev=1492522&r1=1492521&r2=1492522&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py Thu Jun 13 03:37:35 2013
@@ -250,6 +250,10 @@ class PSCP:
 pass    
     
 class BootStrap:
+  TEMP_FOLDER = "/tmp"
+  OS_CHECK_SCRIPT_FILE_TEMPLATE = "os_type_check{0}.sh"
+
+  
   """ BootStrapping the agents on a list of hosts"""
   def __init__(self, hosts, user, sshkeyFile, scriptDir, boottmpdir, setupAgentFile, ambariServer, cluster_os_type, ambariVersion, passwordFile = None):
     self.hostlist = hosts
@@ -265,8 +269,16 @@ class BootStrap:
     self.ambariVersion = ambariVersion
     self.passwordFile = passwordFile
     self.statuses = None
+    """Prepare temp file names"""
+    self.osCheckScriptRemoteLocation = os.path.join(self.TEMP_FOLDER, self.generateRandomFileName(self.OS_CHECK_SCRIPT_FILE_TEMPLATE))
     pass
 
+  def generateRandomFileName(self, fileNameTemplate):
+    if fileNameTemplate == None:
+      return self.getUtime()
+    else:
+      return fileNameTemplate.format(self.getUtime())
+
   # This method is needed  to implement the descriptor protocol (make object  to pass self reference to mockups)
   def __get__(self, obj, objtype):
     def _call(*args, **kwargs):
@@ -293,9 +305,15 @@ class BootStrap:
   def getOsCheckScript(self):
     return os.path.join(self.scriptDir, "os_type_check.sh")
 
+  def getOsCheckScriptRemoteLocation(self):
+    return self.osCheckScriptRemoteLocation
+
   def getSetupScript(self):
     return os.path.join(self.scriptDir, "setupAgent.py")
 
+  def getUtime(self):
+    return int(time.time())
+
   def getPasswordFile(self):
     return "/tmp/host_pass"
 
@@ -314,13 +332,13 @@ class BootStrap:
     else:
       return self.getMoveRepoFileWithoutPasswordCommand(targetDir)
 
-  OS_CHECK_SCRIPT_REMOTE_LOCATION = "/tmp/os_type_check.sh"
+
 
   def copyOsCheckScript(self):
     try:
       # Copying the os check script file
       fileToCopy = self.getOsCheckScript()
-      target = self.OS_CHECK_SCRIPT_REMOTE_LOCATION
+      target = self.getOsCheckScriptRemoteLocation()
       pscp = PSCP(self.successive_hostlist, self.user, self.sshkeyFile, fileToCopy, target, self.bootdir)
       pscp.run()
       out = pscp.getstatus()
@@ -422,8 +440,8 @@ class BootStrap:
   def runOsCheckScript(self):
     logging.info("Running os type check...")
     command = "chmod a+x %s && %s %s" % \
-           (self.OS_CHECK_SCRIPT_REMOTE_LOCATION,
-            self.OS_CHECK_SCRIPT_REMOTE_LOCATION,  self.cluster_os_type)
+           (self.getOsCheckScriptRemoteLocation(),
+            self.getOsCheckScriptRemoteLocation(),  self.cluster_os_type)
 
     pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile, command, self.bootdir)
     pssh.run()