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

[Cluster-devel] [PATCH 12/15] [cleanup] Remove snmp_define_defaults()



This function is always called for SNMP fence agents so it is possible to run it automatically.
---
 fence/agents/apc_snmp/fence_apc_snmp.py         | 11 +++--------
 fence/agents/cisco_mds/fence_cisco_mds.py       |  4 +---
 fence/agents/eaton_snmp/fence_eaton_snmp.py     |  4 +---
 fence/agents/ibmblade/fence_ibmblade.py         |  3 +--
 fence/agents/ifmib/fence_ifmib.py               |  3 +--
 fence/agents/intelmodular/fence_intelmodular.py |  4 +---
 fence/agents/ipdu/fence_ipdu.py                 |  3 +--
 fence/agents/lib/fencing.py.py                  |  3 +++
 fence/agents/lib/fencing_snmp.py.py             |  6 +-----
 9 files changed, 13 insertions(+), 28 deletions(-)

diff --git a/fence/agents/apc_snmp/fence_apc_snmp.py b/fence/agents/apc_snmp/fence_apc_snmp.py
index 2461476..29aafe6 100644
--- a/fence/agents/apc_snmp/fence_apc_snmp.py
+++ b/fence/agents/apc_snmp/fence_apc_snmp.py
@@ -16,7 +16,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="APC SNMP fence agent"
@@ -169,11 +169,6 @@ def get_outlets_status(conn, options):
 
 	return result
 
-# Define new options
-def apc_snmp_define_defaults():
-	all_opt["snmp_version"]["default"] = "1"
-	all_opt["community"]["default"] = "private"
-
 # Main agent method
 def main():
 	device_opt = [ "ipaddr", "login", "passwd", "no_login", "no_password", \
@@ -181,8 +176,8 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-	apc_snmp_define_defaults()
+	all_opt["snmp_version"]["default"] = "1"
+	all_opt["community"]["default"] = "private"
 
 	options = check_input(device_opt, process_input(device_opt))
 
diff --git a/fence/agents/cisco_mds/fence_cisco_mds.py b/fence/agents/cisco_mds/fence_cisco_mds.py
index 6cc189f..84adee2 100644
--- a/fence/agents/cisco_mds/fence_cisco_mds.py
+++ b/fence/agents/cisco_mds/fence_cisco_mds.py
@@ -11,7 +11,7 @@ import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing import fail_usage
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Cisco MDS 9xxx SNMP fence agent"
@@ -84,8 +84,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
diff --git a/fence/agents/eaton_snmp/fence_eaton_snmp.py b/fence/agents/eaton_snmp/fence_eaton_snmp.py
index f519be8..970fd69 100644
--- a/fence/agents/eaton_snmp/fence_eaton_snmp.py
+++ b/fence/agents/eaton_snmp/fence_eaton_snmp.py
@@ -10,7 +10,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Eaton SNMP fence agent"
@@ -204,8 +204,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	all_opt["switch"]["default"] = 1
 	all_opt["power_wait"]["default"] = 2
 	all_opt["snmp_version"]["default"] = "1"
diff --git a/fence/agents/ibmblade/fence_ibmblade.py b/fence/agents/ibmblade/fence_ibmblade.py
index 43bc73e..d1bb065 100644
--- a/fence/agents/ibmblade/fence_ibmblade.py
+++ b/fence/agents/ibmblade/fence_ibmblade.py
@@ -4,7 +4,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IBM Blade SNMP fence agent"
@@ -57,7 +57,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults()
 	all_opt["snmp_version"]["default"] = "1"
 
 	options = check_input(device_opt, process_input(device_opt))
diff --git a/fence/agents/ifmib/fence_ifmib.py b/fence/agents/ifmib/fence_ifmib.py
index 350ce71..f8beaa5 100644
--- a/fence/agents/ifmib/fence_ifmib.py
+++ b/fence/agents/ifmib/fence_ifmib.py
@@ -13,7 +13,7 @@ import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
 from fencing import fail_usage
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IF:MIB SNMP fence agent"
@@ -102,7 +102,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
 	all_opt["snmp_version"]["default"] = "2c"
 
 	options = check_input(device_opt, process_input(device_opt))
diff --git a/fence/agents/intelmodular/fence_intelmodular.py b/fence/agents/intelmodular/fence_intelmodular.py
index 320b2db..e9ef43c 100644
--- a/fence/agents/intelmodular/fence_intelmodular.py
+++ b/fence/agents/intelmodular/fence_intelmodular.py
@@ -15,7 +15,7 @@ import sys
 import atexit
 sys.path.append("@FENCEAGENTSLIBDIR@")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="Intel Modular SNMP fence agent"
@@ -68,8 +68,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
-
 	options = check_input(device_opt, process_input(device_opt))
 
 	docs = { }
diff --git a/fence/agents/ipdu/fence_ipdu.py b/fence/agents/ipdu/fence_ipdu.py
index 62a2df4..83f1dd4 100644
--- a/fence/agents/ipdu/fence_ipdu.py
+++ b/fence/agents/ipdu/fence_ipdu.py
@@ -9,7 +9,7 @@ import sys
 import atexit
 sys.path.append("/usr/share/fence")
 from fencing import *
-from fencing_snmp import *
+from fencing_snmp import FencingSnmp
 
 #BEGIN_VERSION_GENERATION
 RELEASE_VERSION="IBM iPDU SNMP fence agent"
@@ -133,7 +133,6 @@ def main():
 
 	atexit.register(atexit_handler)
 
-	snmp_define_defaults ()
 	all_opt["snmp_version"]["default"] = "3"
 	all_opt["community"]["default"] = "private"
 	all_opt["switch"]["default"] = "1"
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 3409b60..fe4d9c4 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -643,6 +643,9 @@ def check_input(device_opt, opt):
 		if options.has_key("--ipport"):
 			all_opt["ipport"]["help"] = "-u, --ipport=[port]            " + \
 					"TCP/UDP port to use (default " + options["--ipport"] +")"
+		elif device_opt.count("snmp_version"):
+			all_opt["ipport"]["default"] = "161"
+			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default 161)"
 		elif options.has_key("--ssh"):
 			all_opt["ipport"]["default"] = 22
 			all_opt["ipport"]["help"] = "-u, --ipport=[port]            TCP/UDP port to use (default 22)"
diff --git a/fence/agents/lib/fencing_snmp.py.py b/fence/agents/lib/fencing_snmp.py.py
index e65a551..98afd30 100644
--- a/fence/agents/lib/fencing_snmp.py.py
+++ b/fence/agents/lib/fencing_snmp.py.py
@@ -6,7 +6,7 @@ import re, pexpect
 from fencing import *
 from fencing import fail, fail_usage, EC_TIMED_OUT, LOG_MODE_VERBOSE
 
-__all__ = [ 'FencingSnmp', 'snmp_define_defaults' ]
+__all__ = [ 'FencingSnmp' ]
 
 ## do not add code here.
 #BEGIN_VERSION_GENERATION
@@ -15,10 +15,6 @@ REDHAT_COPYRIGHT = ""
 BUILD_DATE = ""
 #END_VERSION_GENERATION
 
-# Fix for RHBZ#527844
-def snmp_define_defaults ():
-	all_opt["ipport"]["default"] = "161"
-
 class FencingSnmp:
 	def __init__(self, options):
 		self.options = options
-- 
1.9.0


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