[Cluster-devel] cluster/fence/agents/apc fence_apc_snmp.py

kupcevic at sourceware.org kupcevic at sourceware.org
Wed Feb 14 09:37:12 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	kupcevic at sourceware.org	2007-02-14 09:37:11

Modified files:
	fence/agents/apc: fence_apc_snmp.py 

Log message:
	fence_apc_snmp ignores "port" parameter

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/apc/fence_apc_snmp.py.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- cluster/fence/agents/apc/fence_apc_snmp.py	2006/08/09 19:22:02	1.2
+++ cluster/fence/agents/apc/fence_apc_snmp.py	2007/02/14 09:37:10	1.3
@@ -17,7 +17,7 @@
 ## located in /usr/share/snmp/mibs/
 #############################################################################
 #############################################################################
-                                                                                
+
 
 
 import getopt, sys
@@ -50,7 +50,7 @@
         print "  -q               quiet mode";
         print "  -V               version";
         print "  -v               Log to file /tmp/apclog";
-                                                                                
+	
         sys.exit(0);
 
 
@@ -89,7 +89,7 @@
         sys.exit(0)
       if o in ("-h", "--help"):
         usage()
-        sys.exit()
+        sys.exit(0)
       if o == "-n":
         port = a
       if o  == "-o":
@@ -123,8 +123,9 @@
     #place params in dict
     for line in sys.stdin:
       val = line.split("=")
-      params[val[0]] = val[1]
-
+      if len(val) == 2:
+        params[val[0].strip()] = val[1].strip()
+    
     try:
       address = params["ipaddr"]
     except KeyError, e:
@@ -135,13 +136,20 @@
     except KeyError, e:
       sys.stderr.write("FENCE: Missing login param for fence_apc...exiting")
       sys.exit(1)
-                                                                                
+    
     try:
       passwd = params["passwd"]
     except KeyError, e:
       sys.stderr.write("FENCE: Missing passwd param for fence_apc...exiting")
       sys.exit(1)
-                                                                                
+    
+    try:
+      port = params["port"]
+    except KeyError, e:
+      sys.stderr.write("FENCE: Missing port param for fence_apc...exiting")
+      sys.exit(1)
+    
+    
     try:
       a = params["option"]
       if a == "Off" or a == "OFF" or a == "off":
@@ -300,13 +308,13 @@
         sys.exit(1)
         
 def execWithCaptureStatus(command, argv, searchPath = 0, root = '/', stdin = 0,
-                    catchfd = 1, closefd = -1):
-                                                                                
+			  catchfd = 1, closefd = -1):
+	
     if not os.access (root + command, os.X_OK):
-        raise RuntimeError, command + " can not be run"
-                                                                                
+        raise RuntimeError, command + " cannot be run"
+    
     (read, write) = os.pipe()
-                                                                                
+    
     childpid = os.fork()
     if (not childpid):
         if (root and root != '/'): os.chroot (root)
@@ -317,42 +325,42 @@
             os.dup2(write, catchfd)
         os.close(write)
         os.close(read)
-                                                                                
+	
         if closefd != -1:
             os.close(closefd)
-                                                                                
+	
         if stdin:
             os.dup2(stdin, 0)
             os.close(stdin)
-                                                                                
+	
         if (searchPath):
             os.execvp(command, argv)
         else:
             os.execv(command, argv)
-                                                                                
+	
         sys.exit(1)
-                                                                                
+    
     os.close(write)
-                                                                                
+    
     rc = ""
     s = "1"
     while (s):
         select.select([read], [], [])
         s = os.read(read, 1000)
         rc = rc + s
-                                                                                
+    
     os.close(read)
-                                                                                
+    
     try:
         (pid, status) = os.waitpid(childpid, 0)
     except OSError, (errno, msg):
         print __name__, "waitpid:", msg
-                                                                                
+    
     if os.WIFEXITED(status) and (os.WEXITSTATUS(status) == 0):
         status = os.WEXITSTATUS(status)
     else:
         status = -1
-                                                                                
+    
     return (rc, status)
 
 if __name__ == "__main__":




More information about the Cluster-devel mailing list