* [Cluster-devel] [PATCH 1/2] fencing: Add support for options which should be selected from a list of values
@ 2013-11-20 16:35 Marek 'marx' Grac
2013-11-20 16:35 ` [Cluster-devel] [PATCH 2/2] fencing: Add information about option that have to be selected from list to XML metadata Marek 'marx' Grac
0 siblings, 1 reply; 2+ messages in thread
From: Marek 'marx' Grac @ 2013-11-20 16:35 UTC (permalink / raw)
To: cluster-devel.redhat.com
Previously, we have supported only strings and booleans; this is first patch that adds
support for entering constrains like select a proper SNMP version from [1, 2c, 3].
---
fence/agents/drac5/fence_drac5.py | 1 +
fence/agents/lib/fencing.py.py | 20 +++++++++++++-------
fence/agents/lpar/fence_lpar.py | 4 +---
3 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/fence/agents/drac5/fence_drac5.py b/fence/agents/drac5/fence_drac5.py
index aa432c2..2c067a7 100644
--- a/fence/agents/drac5/fence_drac5.py
+++ b/fence/agents/drac5/fence_drac5.py
@@ -96,6 +96,7 @@ def define_new_opts():
"help" : "-d, --drac-version=[version] Force DRAC version to use (DRAC 5, DRAC CMC, DRAC MC)",
"required" : "0",
"shortdesc" : "Force DRAC version to use (DRAC 5, DRAC CMC, DRAC MC)",
+ "choices" : [ "DRAC CMC", "DRAC MC", "DRAC 5" ],
"order" : 1 }
def main():
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0ef0934..a19ae20 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -142,13 +142,6 @@ all_opt = {
"required" : "0",
"shortdesc" : "Identity file for ssh",
"order" : 1 },
- "drac_version" : {
- "getopt" : "d:",
- "longopt" : "drac-version",
- "help" : "-d, --drac-version=[version] Force DRAC version to use",
- "required" : "0",
- "shortdesc" : "Force DRAC version to use",
- "order" : 1 },
"cmd_prompt" : {
"getopt" : "c:",
"longopt" : "command-prompt",
@@ -219,6 +212,7 @@ all_opt = {
"help" : "-d, --snmp-version=[version] Specifies SNMP version to use",
"required" : "0",
"shortdesc" : "Specifies SNMP version to use (1,2c,3)",
+ "choices" : [ "1", "2c", "3" ],
"order" : 1 },
"community" : {
"getopt" : "c:",
@@ -233,6 +227,7 @@ all_opt = {
"help" : "-b, --snmp-auth-prot=[prot] Set authentication protocol (MD5|SHA)",
"required" : "0",
"shortdesc" : "Set authentication protocol (MD5|SHA)",
+ "choices" : [ "MD5" , "SHA" ],
"order" : 1},
"snmp_sec_level" : {
"getopt" : "E:",
@@ -241,6 +236,7 @@ all_opt = {
" (noAuthNoPriv|authNoPriv|authPriv)",
"required" : "0",
"shortdesc" : "Set security level (noAuthNoPriv|authNoPriv|authPriv)",
+ "choices" : [ "noAuthNoPriv", "authNoPriv", "authPriv" ],
"order" : 1},
"snmp_priv_prot" : {
"getopt" : "B:",
@@ -248,6 +244,7 @@ all_opt = {
"help" : "-B, --snmp-priv-prot=[prot] Set privacy protocol (DES|AES)",
"required" : "0",
"shortdesc" : "Set privacy protocol (DES|AES)",
+ "choices" : [ "DES", "AES" ],
"order" : 1},
"snmp_priv_passwd" : {
"getopt" : "P:",
@@ -721,6 +718,15 @@ def check_input(device_opt, opt):
else:
options["--ipport"] = 23
+ for opt in device_opt:
+ if all_opt[opt].has_key("choices"):
+ long = "--" + all_opt[opt]["longopt"]
+ possible_values_upper = map (lambda y : y.upper(), all_opt[opt]["choices"])
+ if options.has_key(long):
+ options[long] = options[long].upper()
+ if not options["--" + all_opt[opt]["longopt"]] in possible_values_upper:
+ fail_usage("Failed: You have to enter a valid choice for %s from the valid values: %s" % ("--" + all_opt[opt]["longopt"] , str(all_opt[opt]["choices"])))
+
return options
def wait_power_status(tn, options, get_power_fn):
diff --git a/fence/agents/lpar/fence_lpar.py b/fence/agents/lpar/fence_lpar.py
index 6d2c649..1d7e09c 100644
--- a/fence/agents/lpar/fence_lpar.py
+++ b/fence/agents/lpar/fence_lpar.py
@@ -114,6 +114,7 @@ def define_new_opts():
"required" : "0",
"shortdesc" : "Force HMC version to use (3 or 4)",
"default" : "4",
+ "choices" : [ "3", "4" ],
"order" : 1 }
def main():
@@ -139,9 +140,6 @@ def main():
if 0 == options.has_key("--managed"):
fail_usage("Failed: You have to enter name of managed system")
- if 1 == options.has_key("--hmc-version") and (options["--hmc-version"] != "3" and options["--hmc-version"] != "4"):
- fail_usage("Failed: You have to enter valid version number: 3 or 4")
-
##
## Operate the fencing device
####
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [PATCH 2/2] fencing: Add information about option that have to be selected from list to XML metadata
2013-11-20 16:35 [Cluster-devel] [PATCH 1/2] fencing: Add support for options which should be selected from a list of values Marek 'marx' Grac
@ 2013-11-20 16:35 ` Marek 'marx' Grac
0 siblings, 0 replies; 2+ messages in thread
From: Marek 'marx' Grac @ 2013-11-20 16:35 UTC (permalink / raw)
To: cluster-devel.redhat.com
---
fence/agents/lib/fencing.py.py | 7 ++++++-
fence/agents/lib/metadata.rng | 24 ++++++++++++++++++------
2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index a19ae20..2b914f2 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -477,7 +477,12 @@ def metadata(avail_opt, options, docs):
mixed = mixed.replace("<", "<").replace(">", ">")
print "\t\t<getopt mixed=\"" + mixed + "\" />"
- if all_opt[option]["getopt"].count(":") > 0:
+ if all_opt[option].has_key("choices"):
+ print "\t\t<content type=\"select\" "+default+" >"
+ for choice in all_opt[option]["choices"]:
+ print "\t\t\t<option value=\"%s\" />" % (choice)
+ print "\t\t</content>"
+ elif all_opt[option]["getopt"].count(":") > 0:
print "\t\t<content type=\"string\" "+default+" />"
else:
print "\t\t<content type=\"boolean\" "+default+" />"
diff --git a/fence/agents/lib/metadata.rng b/fence/agents/lib/metadata.rng
index 2566fee..c7758e6 100644
--- a/fence/agents/lib/metadata.rng
+++ b/fence/agents/lib/metadata.rng
@@ -24,12 +24,24 @@
<attribute name="mixed" />
</element>
<element name="content">
- <attribute name="type">
- <choice>
- <value>boolean</value>
- <value>string</value>
- </choice>
- </attribute>
+ <choice>
+ <attribute name="type">
+ <choice>
+ <value>boolean</value>
+ <value>string</value>
+ </choice>
+ </attribute>
+ <group>
+ <attribute name="type">
+ <value>select</value>
+ </attribute>
+ <zeroOrMore>
+ <element name="option">
+ <attribute name="value" />
+ </element>
+ </zeroOrMore>
+ </group>
+ </choice>
<optional>
<attribute name="default"> <text /> </attribute>
</optional>
--
1.7.7.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-20 16:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-20 16:35 [Cluster-devel] [PATCH 1/2] fencing: Add support for options which should be selected from a list of values Marek 'marx' Grac
2013-11-20 16:35 ` [Cluster-devel] [PATCH 2/2] fencing: Add information about option that have to be selected from list to XML metadata Marek 'marx' Grac
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 NNTP newsgroup(s).