public inbox for cluster-cvs@sourceware.org
help / color / mirror / Atom feed
* fence-agents: master - fence: Add support for IPv4/IPv6 forcing
@ 2009-03-26 17:12 Jan Friesse
  0 siblings, 0 replies; only message in thread
From: Jan Friesse @ 2009-03-26 17:12 UTC (permalink / raw)
  To: cluster-cvs-relay

Gitweb:        http://git.fedorahosted.org/git/fence-agents.git?p=fence-agents.git;a=commitdiff;h=b4a926af09e6f88aabdfb4e33c073d5851e4c2a7
Commit:        b4a926af09e6f88aabdfb4e33c073d5851e4c2a7
Parent:        883a960946bfe7e19e34354d837f6ad7157c93a6
Author:        Jan Friesse <jfriesse@redhat.com>
AuthorDate:    Thu Mar 26 18:11:20 2009 +0100
Committer:     Jan Friesse <jfriesse@redhat.com>
CommitterDate: Thu Mar 26 18:11:20 2009 +0100

fence: Add support for IPv4/IPv6 forcing

Support is added for agents written in Python, which
uses standard fencing library and connecting
by SNMP/nss_wrapper or SSH.

Sadly telnet distributed with Fedora/RHEL doesn't
has support for forcing IPv4/IPv6 connection, so
it's impossible to implement this feature for agents
using it.
---
 fence/agents/alom/fence_alom.py                 |    2 +-
 fence/agents/apc/fence_apc.py                   |    3 +-
 fence/agents/apc_snmp/fence_apc_snmp.py         |    2 +-
 fence/agents/bladecenter/fence_bladecenter.py   |    3 +-
 fence/agents/cisco_mds/fence_cisco_mds.py       |    2 +-
 fence/agents/drac/fence_drac5.py                |    2 +-
 fence/agents/ibmblade/fence_ibmblade.py         |    2 +-
 fence/agents/ifmib/fence_ifmib.py               |    2 +-
 fence/agents/ilo/fence_ilo.py                   |    2 +-
 fence/agents/intelmodular/fence_intelmodular.py |    2 +-
 fence/agents/ldom/fence_ldom.py                 |    2 +-
 fence/agents/lib/fencing.py.py                  |   28 ++++++++++++++++++++--
 fence/agents/lib/fencing_snmp.py.py             |   10 +++++++-
 fence/agents/lpar/fence_lpar.py                 |    2 +-
 fence/agents/virsh/fence_virsh.py               |    3 +-
 fence/agents/wti/fence_wti.py                   |    2 +-
 16 files changed, 51 insertions(+), 18 deletions(-)

diff --git a/fence/agents/alom/fence_alom.py b/fence/agents/alom/fence_alom.py
index 969ed21..0a1de93 100644
--- a/fence/agents/alom/fence_alom.py
+++ b/fence/agents/alom/fence_alom.py
@@ -45,7 +45,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure",  "test" ]
+			"secure",  "test", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/apc/fence_apc.py b/fence/agents/apc/fence_apc.py
index f40ffeb..9fa3ec6 100755
--- a/fence/agents/apc/fence_apc.py
+++ b/fence/agents/apc/fence_apc.py
@@ -184,7 +184,8 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "port", "switch", "test", "separator" ]
+			"secure", "port", "switch", "test", "separator",
+			"force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 8cdb169..3007b2d 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -169,7 +169,7 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport"]
+		       "udpport","force_ipv4","force_ipv6"]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/bladecenter/fence_bladecenter.py b/fence/agents/bladecenter/fence_bladecenter.py
index 3e277e1..fc88656 100644
--- a/fence/agents/bladecenter/fence_bladecenter.py
+++ b/fence/agents/bladecenter/fence_bladecenter.py
@@ -90,7 +90,8 @@ def get_blades_list(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"cmd_prompt", "secure", "port", "identity_file", "separator" ]
+			"cmd_prompt", "secure", "port", "identity_file", "separator",
+			"force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 76a45d4..5d910dd 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -86,7 +86,7 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport"]
+		       "udpport","force_ipv4","force_ipv6"]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/drac/fence_drac5.py b/fence/agents/drac/fence_drac5.py
index dbe05d1..6519487 100755
--- a/fence/agents/drac/fence_drac5.py
+++ b/fence/agents/drac/fence_drac5.py
@@ -52,7 +52,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"cmd_prompt", "secure",
-			"drac_version", "module_name" ]
+			"drac_version", "module_name", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index 073da78..811d311 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -61,7 +61,7 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport"]
+		       "udpport","force_ipv4","force_ipv6"]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index 0f955ac..d5d193f 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -106,7 +106,7 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport"]
+		       "udpport","force_ipv4","force_ipv6"]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/ilo/fence_ilo.py b/fence/agents/ilo/fence_ilo.py
index fafade1..19d04db 100755
--- a/fence/agents/ilo/fence_ilo.py
+++ b/fence/agents/ilo/fence_ilo.py
@@ -56,7 +56,7 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"ssl", "ribcl" ]
+			"ssl", "ribcl", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index ea2453a..0ac86dc 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -72,7 +72,7 @@ def main():
 		       "test", "port", "separator", "no_login", "no_password",
 		       "snmp_version", "community", "snmp_auth_prot", "snmp_sec_level",
 		       "snmp_priv_prot", "snmp_priv_passwd", "snmp_priv_passwd_script",
-		       "udpport"]
+		       "udpport","force_ipv4","force_ipv6"]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/ldom/fence_ldom.py b/fence/agents/ldom/fence_ldom.py
index 7bcca39..07f90ca 100644
--- a/fence/agents/ldom/fence_ldom.py
+++ b/fence/agents/ldom/fence_ldom.py
@@ -84,7 +84,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure",  "identity_file", "test" , "port", "cmd_prompt",
-			"separator" ]
+			"separator", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 34b0caa..a4d666f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -257,6 +257,20 @@ all_opt = {
 		"required" : "0",
 		"shortdesc" : "Script to run to retrieve privacy password",
 		"order" : 1},
+	"force_ipv4" : {
+		"getopt" : "4",
+		"longopt" : "force-ipv4",
+		"help" : "-4, --force-ipv4               Forces agent to use IPv4 addresses only",
+		"required" : "0",
+		"shortdesc" : "Forces agent to use IPv4 addresses only",
+		"order" : 1 },
+	"force_ipv6" : {
+		"getopt" : "6",
+		"longopt" : "force-ipv6",
+		"help" : "-6, --force-ipv6               Forces agent to use IPv6 addresses only",
+		"required" : "0",
+		"shortdesc" : "Forces agent to use IPv6 addresses only",
+		"order" : 1 },
 	"udpport" : {
 		"getopt" : "u:",
 		"longopt" : "udpport",
@@ -599,15 +613,23 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
 		1
 
 def fence_login(options):
+	force_ipvx=""
+
+	if (options.has_key("-6")):
+		force_ipvx="-6 "
+
+	if (options.has_key("-4")):
+		force_ipvx="-4 "
+
 	try:
 		re_login = re.compile("(login: )|(Login Name:  )|(username: )|(User Name :)", re.IGNORECASE)
 		re_pass  = re.compile("password", re.IGNORECASE)
 
 		if options.has_key("-z"):
-			command = '%s %s %s' % (SSL_PATH, options["-a"], "443")
+			command = '%s %s %s %s' % (SSL_PATH, force_ipvx, options["-a"], "443")
 			conn = fspawn(command)
 		elif options.has_key("-x") and 0 == options.has_key("-k"):
-			command = '%s %s@%s' % (SSH_PATH, options["-l"], options["-a"])
+			command = '%s %s %s@%s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
@@ -630,7 +652,7 @@ def fence_login(options):
 			conn.sendline(options["-p"])
 			conn.log_expect(options, options["-c"], LOGIN_TIMEOUT)
 		elif options.has_key("-x") and 1 == options.has_key("-k"):
-			command = '%s %s@%s -i %s' % (SSH_PATH, options["-l"], options["-a"], options["-k"])
+			command = '%s %s %s@%s -i %s' % (SSH_PATH, force_ipvx, options["-l"], options["-a"], options["-k"])
 			if options.has_key("ssh_options"):
 				command += ' ' + options["ssh_options"]
 			conn = fspawn(command)
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index e2a1760..146f304 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -59,7 +59,15 @@ class FencingSnmp:
 			if (self.options.has_key("-"+item[0])):
 				cmd+=" -%s '%s'"%(item[1],self.quote_for_run(self.options["-"+item[0]]))
 
-		cmd+=" '%s%s'"%(self.quote_for_run(self.options["-a"]),
+		force_ipvx=""
+
+		if (self.options.has_key("-6")):
+			force_ipvx="udp6:"
+
+		if (self.options.has_key("-4")):
+			force_ipvx="udp:"
+
+		cmd+=" '%s%s%s'"%(force_ipvx, self.quote_for_run(self.options["-a"]),
 				self.options.has_key("-u") and self.quote_for_run(":"+self.options["-u"]) or "")
 		return cmd
 
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 2d03b14..505e21c 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -133,7 +133,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure", "partition", "managed", "hmc_version", "cmd_prompt",
-			"separator" ]
+			"separator", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 2c1018a..6e7e291 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -62,7 +62,8 @@ def set_power_status(conn, options):
 def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
-			"secure", "identity_file", "test", "port", "separator" ]
+			"secure", "identity_file", "test", "port", "separator",
+			"force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 
diff --git a/fence/agents/wti/fence_wti.py b/fence/agents/wti/fence_wti.py
index a8927a9..d11d3b1 100644
--- a/fence/agents/wti/fence_wti.py
+++ b/fence/agents/wti/fence_wti.py
@@ -76,7 +76,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"cmd_prompt", "secure", "port", "no_login", "no_password",
-			"test", "separator" ]
+			"test", "separator", "force_ipv4", "force_ipv6" ]
 
 	atexit.register(atexit_handler)
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-03-26 17:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-26 17:12 fence-agents: master - fence: Add support for IPv4/IPv6 forcing Jan Friesse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).