Author: smohanty
Date: Tue Apr 23 23:01:03 2013
New Revision: 1471190
URL: http://svn.apache.org/r1471190
Log:
AMBARI-2008. Using mixed OS overwrites ambari.repo during install. (smohanty)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py
incubator/ambari/trunk/ambari-server/src/test/python/TestBootstrap.py
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1471190&r1=1471189&r2=1471190&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Apr 23 23:01:03 2013
@@ -774,6 +774,8 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-2008. Using mixed OS overwrites ambari.repo during install. (smohanty)
+
AMBARI-1952. hadoop dependency version for ambari-log4j is hardcoded, making
it regular expression based to pick latest from the repository. (smohanty)
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=1471190&r1=1471189&r2=1471190&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/bootstrap.py Tue Apr
23 23:01:03 2013
@@ -321,7 +321,7 @@ class BootStrap:
# Copying the os check script file
fileToCopy = self.getOsCheckScript()
target = self.OS_CHECK_SCRIPT_REMOTE_LOCATION
- pscp = PSCP(self.hostlist, self.user, self.sshkeyFile, fileToCopy,
target, self.bootdir)
+ pscp = PSCP(self.successive_hostlist, self.user, self.sshkeyFile,
fileToCopy, target, self.bootdir)
pscp.run()
out = pscp.getstatus()
# Preparing report about failed hosts
@@ -366,7 +366,7 @@ class BootStrap:
pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile,
command, self.bootdir)
pssh.run()
out = pssh.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
failed_current = get_difference(self.successive_hostlist,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
failed = get_difference(self.hostlist, self.successive_hostlist)
@@ -386,8 +386,8 @@ class BootStrap:
". Failed on last step: " + str(failed_current))
#updating statuses
self.statuses = unite_statuses(self.statuses, out)
- retstatus = 0
- if not failed:
+
+ if not failed:
retstatus = 0
else:
retstatus = 1
@@ -438,7 +438,7 @@ class BootStrap:
#updating statuses
self.statuses = unite_statuses(self.statuses, out)
- retstatus = 0
+
if not failed:
retstatus = 0
else:
@@ -461,7 +461,7 @@ class BootStrap:
#updating statuses
self.statuses = unite_statuses(self.statuses, out)
- retstatus = 0
+
if not failed:
retstatus = 0
else:
@@ -483,18 +483,19 @@ class BootStrap:
try:
""" Checking 'sudo' package on remote hosts """
command = "rpm -qa | grep sudo"
- pssh = PSSH(self.hostlist, self.user, self.sshkeyFile, command,
self.bootdir, "Error: Sudo command is not available. Please install the sudo
command.")
+ pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile,
command, self.bootdir, "Error: Sudo command is not available. Please install
the sudo command.")
pssh.run()
out = pssh.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
+ failed_current = get_difference(self.successive_hostlist,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
failed = get_difference(self.hostlist, self.successive_hostlist)
- logging.info("Parallel ssh returns for checking 'sudo' package. Failed
hosts are: " + str(failed))
+ logging.info("Parallel ssh returns for checking 'sudo' package. All
failed hosts are: " + str(failed) +
+ ". Failed on last step: " + str(failed_current))
#updating statuses
- self.statuses = out
+ self.statuses = unite_statuses(self.statuses, out)
- retstatus = 0
- if not failed:
+ if not failed:
retstatus = 0
else:
retstatus = 1
@@ -512,7 +513,7 @@ class BootStrap:
pscp = PSCP(self.successive_hostlist, self.user, self.sshkeyFile,
self.passwordFile, "/tmp", self.bootdir)
pscp.run()
out = pscp.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
failed_current = get_difference(self.successive_hostlist,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
self.hostlist_to_remove_password_file = self.successive_hostlist
@@ -529,7 +530,7 @@ class BootStrap:
pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile,
command, self.bootdir)
pssh.run()
out = pssh.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
failed_current = get_difference(self.successive_hostlist,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
failed = get_difference(self.hostlist, self.successive_hostlist)
@@ -558,7 +559,7 @@ class BootStrap:
pssh = PSSH(self.successive_hostlist, self.user, self.sshkeyFile,
command, self.bootdir)
pssh.run()
out = pssh.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
failed_current = get_difference(self.successive_hostlist,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
failed = get_difference(self.hostlist, self.successive_hostlist)
@@ -587,7 +588,7 @@ class BootStrap:
pssh = PSSH(self.hostlist_to_remove_password_file, self.user,
self.sshkeyFile, command, self.bootdir)
pssh.run()
out = pssh.getstatus()
- # Prepearing report about failed hosts
+ # Preparing report about failed hosts
failed_current = get_difference(self.hostlist_to_remove_password_file,
skip_failed_hosts(out))
self.successive_hostlist = skip_failed_hosts(out)
failed = get_difference(self.hostlist, self.successive_hostlist)
Modified: incubator/ambari/trunk/ambari-server/src/test/python/TestBootstrap.py
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/python/TestBootstrap.py?rev=1471190&r1=1471189&r2=1471190&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/python/TestBootstrap.py
(original)
+++ incubator/ambari/trunk/ambari-server/src/test/python/TestBootstrap.py Tue
Apr 23 23:01:03 2013
@@ -80,6 +80,12 @@ class TestBootstrap(TestCase):
SSH_writeDoneToFile_method.return_value = None
communicate_method.return_value = ("", "")
bootstrap = BootStrap(["hostname"], "root", "sshKeyFile", "scriptDir",
"bootdir", "setupAgentFile", "ambariServer", "centos6", None)
+ bootstrap.statuses = {
+ "hostname" : {
+ "exitstatus" : 0,
+ "log" : ""
+ }
+ }
ret = bootstrap.checkSudoPackage()
self.assertTrue("Error: Sudo command is not available. Please install the
sudo command." in bootstrap.statuses["hostname"]["log"])
@@ -347,3 +353,72 @@ class TestBootstrap(TestCase):
bootstrap = BootStrap(["hostname"], "user", "sshKeyFile", "scriptDir",
"bootdir", "setupAgentFile", "ambariServer", "centos6", version)
runSetupCommand = bootstrap.getRunSetupCommand()
self.assertTrue(runSetupCommand.endswith("ambariServer "))
+
+
+ @patch.object(BootStrap, "createDoneFiles")
+ @patch.object(PSCP, "getstatus")
+ @patch.object(PSCP, "run")
+ @patch.object(PSSH, "getstatus")
+ @patch.object(PSSH, "run")
+ def test_os_check_fail_fails_bootstrap_execution(self,
+ pssh_run_method, pssh_getstatus_method,
+ pscp_run_method, pscp_getstatus_method, createDoneFiles_method):
+
+ c6hstr = "cent6host"
+ c5hstr = "cent5host"
+
+ def pscp_statuses():
+ yield { # copyOsCheckScript call
+ c6hstr : {
+ "exitstatus" : 0,
+ "log" : ""
+ },
+ c5hstr : {
+ "exitstatus" : 0,
+ "log" : ""
+ },
+ }
+ while True: # Next calls
+ d = {}
+ for host in bootstrap.successive_hostlist:
+ d[host] = {
+ "exitstatus" : 0,
+ "log" : ""
+ }
+ yield d
+
+ def pssh_statuses():
+ yield { # runOsCheckScript call
+ c6hstr : {
+ "exitstatus" : 0,
+ "log" : ""
+ },
+ c5hstr : {
+ "exitstatus" : 1,
+ "log" : ""
+ },
+ }
+ while True: # Next calls
+ d = {}
+ for host in bootstrap.successive_hostlist:
+ d[host] = {
+ "exitstatus" : 0,
+ "log" : ""
+ }
+ yield d
+
+ pscp_getstatus_method.side_effect = pscp_statuses().next
+ pssh_getstatus_method.side_effect = pssh_statuses().next
+
+
+ os.environ[AMBARI_PASSPHRASE_VAR_NAME] = ""
+ bootstrap = BootStrap([c6hstr, c5hstr], "user", "sshKeyFile", "scriptDir",
+ "bootdir", "setupAgentFile", "ambariServer",
+ "centos6", None)
+ ret = bootstrap.run()
+
+ self.assertTrue(c5hstr not in bootstrap.successive_hostlist)
+ self.assertTrue(c6hstr in bootstrap.successive_hostlist)
+ self.assertTrue(pssh_run_method.call_count >= 2)
+ self.assertTrue(pssh_getstatus_method.call_count >= 2)
+ self.assertTrue(ret == 1)
\ No newline at end of file