[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.02-27-gd1d2954



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=d1d29545d7efeefbe4cd540bdd3dfd248d2310c0

The branch, master has been updated
       via  d1d29545d7efeefbe4cd540bdd3dfd248d2310c0 (commit)
       via  402682f083cf62426fc1878280a6fabb4be14e7d (commit)
       via  fdcffe0beb6d3f7558993f68f82afd388ccdcf5b (commit)
      from  1413ec43636f18ceeed45d7dcfe68e8a0ec52b6c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit d1d29545d7efeefbe4cd540bdd3dfd248d2310c0
Author: Ryan McCabe <rmccabe redhat com>
Date:   Wed May 28 16:30:42 2008 -0400

    libfence: update copyright notice
    
    - Clarify copyright notice so that GPLv2 is specified explicitly.

commit 402682f083cf62426fc1878280a6fabb4be14e7d
Author: Ryan McCabe <rmccabe redhat com>
Date:   Wed May 28 16:29:36 2008 -0400

    libfence: handle EINTR correctly
    
    - Handle EINTR correctly
    - String cleanups

commit fdcffe0beb6d3f7558993f68f82afd388ccdcf5b
Author: Ryan McCabe <rmccabe redhat com>
Date:   Wed May 28 16:28:34 2008 -0400

    fence: fixes and cleanups to fencing.py library
    
    - Do not report failure if a node is successfully powered off,
      but fails to power on.
    
    - Change 'pass' to 'continue' so that comments and blank lines
      from stdin are ignored.
    
    - Use the full path to ssh and telnet when executing the binaries.

-----------------------------------------------------------------------

Summary of changes:
 fence/agents/lib/fencing.py.py |   37 +++++++++++++++++-------------
 fence/libfence/agent.c         |   49 ++++++++++++++++++++++-----------------
 fence/libfence/libfence.h      |    5 +--
 3 files changed, 51 insertions(+), 40 deletions(-)

diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 944553c..300183a 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -10,9 +10,9 @@ import telnetlib
 
 ## do not add code here.
 #BEGIN_VERSION_GENERATION
-RELEASE_VERSION="New fence lib agent - test release on steroids"
-REDHAT_COPYRIGHT=""
-BUILD_DATE="March, 2008"
+RELEASE_VERSION = "New fence lib agent - test release on steroids"
+REDHAT_COPYRIGHT = ""
+BUILD_DATE = "March, 2008"
 #END_VERSION_GENERATION
 
 POWER_TIMEOUT = 20
@@ -29,6 +29,9 @@ EC_TIMED_OUT       = 5
 EC_WAITING_ON      = 6
 EC_WAITING_OFF     = 7
 
+TELNET_PATH = "/usr/bin/telnet"
+SSH_PATH    = "/usr/bin/ssh"
+
 all_opt = {
 	"help"    : {
 		"getopt" : "h",
@@ -132,10 +135,10 @@ class fspawn(pexpect.spawn):
 			options["debug_fh"].write(self.before + self.after)
 		return result
 
-def version(command, release, build_date, copyright):
-	print command, " ", release, " ", build_date;
-	if len(copyright) > 0:
-		print copyright
+def version(command, release, build_date, copyright_notice):
+	print command, " ", release, " ", build_date
+	if len(copyright_notice) > 0:
+		print copyright_notice
 
 def fail_usage(message = ""):
 	if len(message) > 0:
@@ -174,7 +177,8 @@ def process_input(avail_opt):
 	##
 	## Set standard environment
 	#####
-	os.unsetenv("LANG")
+	os.putenv("LANG", "C")
+	os.putenv("LC_ALL", "C")
 
 	##
 	## Prepare list of options for getopt
@@ -184,7 +188,7 @@ def process_input(avail_opt):
 		if all_opt.has_key(k):
 			getopt_string += all_opt[k]["getopt"]
 		else:
-			fail_usage("Parse error: unknown option '"+k+"'");
+			fail_usage("Parse error: unknown option '"+k+"'")
 
 	##
 	## Read options from command line or standard input
@@ -209,7 +213,8 @@ def process_input(avail_opt):
 		name = ""
 		for line in sys.stdin.readlines():
 			line = line.strip()
-			if ((line.startswith("#")) or (len(line) == 0)): pass
+			if ((line.startswith("#")) or (len(line) == 0)):
+				continue
 
 			(name, value) = (line + "=").split("=", 1)
 			value = value[:-1]
@@ -302,7 +307,7 @@ def check_input(device_opt, opt):
 	return options
 	
 def wait_power_status(tn, options, get_power_fn):
-	for x in range(POWER_TIMEOUT):
+	for dummy in xrange(POWER_TIMEOUT):
 		if get_power_fn(tn, options) != options["-o"]:
 			time.sleep(1)
 		else:
@@ -339,7 +344,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn):
 		options["-o"] = "on"
 		set_power_fn(tn, options)
 		if wait_power_status(tn, options, get_power_fn) == 0:
-			fail(EC_WAITING_ON)
+			sys.stderr.write('Timed out waiting to power ON\n')
 		print "Success: Rebooted"
 	elif options["-o"] == "status":
 		print "Status: " + status.upper()
@@ -350,10 +355,10 @@ def fence_login(options):
 		re_pass  = re.compile("password", re.IGNORECASE)
 
 		if options.has_key("-x") and 0 == options.has_key("-k"):
-			command = 'ssh ' + options["-l"] + "@" + options["-a"]
+			command = '%s %s %s' % (SSH_PATH, options["-l"], options["-a"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
-			conn = fspawn (command)
+			conn = fspawn(command)
 			result = conn.log_expect(options, [ "ssword:", "Are you sure you want to continue connecting (yes/no)?" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
@@ -361,7 +366,7 @@ def fence_login(options):
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], SHELL_TIMEOUT)
 		elif options.has_key("-x") and 1 == options.has_key("-k"):
-			conn = fspawn ('ssh ' + options["-l"] + "@" + options["-a"] + " -i " + options["-k"])
+			conn = fspawn('%s %s %s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"]))
 			result = conn.log_expect(options, [ options["-c"], "Are you sure you want to continue connecting (yes/no)?", "Enter passphrase for key '"+options["-k"]+"':" ], LOGIN_TIMEOUT)
 			if result == 1:
 				conn.sendline("yes")
@@ -373,7 +378,7 @@ def fence_login(options):
 				else:
 					fail_usage("Failed: You have to enter passphrase (-p) for identity file")
 		else:
-			conn = fspawn ('telnet ' + options["-a"])
+			conn = fspawn('%s %s' % (TELNET_PATH, options["-a"]))
 			conn.log_expect(options, re_login, LOGIN_TIMEOUT)
 			conn.send(options["-l"]+"\r\n")
 			conn.log_expect(options, re_pass, SHELL_TIMEOUT)
diff --git a/fence/libfence/agent.c b/fence/libfence/agent.c
index cc1508a..9b9e252 100644
--- a/fence/libfence/agent.c
+++ b/fence/libfence/agent.c
@@ -36,28 +36,27 @@
 
 
 
-static void display_agent_output(char *agent, int fd)
+static void display_agent_output(const char *agent, int fd)
 {
-	char msg[512], buf[256];
-
-	memset(msg, 0, sizeof(msg));
-	memset(buf, 0, sizeof(buf));
-
-	while (read(fd, buf, sizeof(buf)-1) > 0) {
-		snprintf(msg, 256, "agent \"%s\" reports: ", agent);
-		strcat(msg, buf);
-
-		/* printf("%s\n", msg); */
-		syslog(LOG_ERR, "%s", msg);
-
-		memset(buf, 0, sizeof(buf));
-		memset(msg, 0, sizeof(msg));
-	}
+	char buf[384];
+	int ret;
+
+	do {
+		ret = read(fd, buf, sizeof(buf) - 1);
+		if (ret < 0) {
+			if (errno == EINTR)
+				continue;
+			break;
+		} else if (ret > 0) {
+			buf[ret] = '\0';
+			syslog(LOG_ERR, "agent \"%s\" reports: %s", agent, buf);
+		}
+	} while (ret > 0);
 }
 
 static int run_agent(char *agent, char *args)
 {
-	int pid, status, error, len = strlen(args);
+	int pid, status, len;
 	int pr_fd, pw_fd;  /* parent read/write file descriptors */
 	int cr_fd, cw_fd;  /* child read/write file descriptors */
 	int fd1[2];
@@ -65,27 +64,35 @@ static int run_agent(char *agent, char *args)
 
 	cr_fd = cw_fd = pr_fd = pw_fd = -1;
 
+	if (args == NULL || agent == NULL)
+		goto fail;
+	len = strlen(args);
+
 	if (pipe(fd1))
 		goto fail;
   	pr_fd = fd1[0];
   	cw_fd = fd1[1];
 
   	if (pipe(fd2))
-    		goto fail;
+   		goto fail;
   	cr_fd = fd2[0];
   	pw_fd = fd2[1];
 
 	pid = fork();
 	if (pid < 0)
-    		goto fail;
+   		goto fail;
 
 	if (pid) {
 		/* parent */
+		int ret;
 
 		fcntl(pr_fd, F_SETFL, fcntl(pr_fd, F_GETFL, 0) | O_NONBLOCK);
 
-		error = write(pw_fd, args, len);
-		if (error != len)
+		do {
+			ret = write(pw_fd, args, len);
+		} while (ret < 0 && errno == EINTR);
+
+		if (ret != len)
 			goto fail;
 
 		close(pw_fd);
diff --git a/fence/libfence/libfence.h b/fence/libfence/libfence.h
index 6cdbd85..53b9f64 100644
--- a/fence/libfence/libfence.h
+++ b/fence/libfence/libfence.h
@@ -4,9 +4,8 @@
 **  Copyright (C) 2008 Red Hat, Inc.  All rights reserved.
 **
 **  This library is free software; you can redistribute it and/or
-**  modify it under the terms of the GNU Lesser General Public
-**  License as published by the Free Software Foundation; either
-**  version 2 of the License, or (at your option) any later version.
+**  modify it under the terms of version 2 of the GNU Lesser General
+**  Public License as published by the Free Software Foundation.
 **
 **  This library is distributed in the hope that it will be useful,
 **  but WITHOUT ANY WARRANTY; without even the implied warranty of


hooks/post-receive
--
Cluster Project


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]