Gitweb: http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=0c33223d4... Commit: 0c33223d4b2e50edaee033d78a4391272d483a7a Parent: b746cdbe59db607fa08ba5aadb00196d2677c93c Author: Marek 'marx' Grac mgrac@redhat.com AuthorDate: Wed Jan 7 14:39:25 2015 +0100 Committer: Marek 'marx' Grac mgrac@redhat.com CommitterDate: Wed Jan 7 14:39:25 2015 +0100
fencing: Validate if short "getopt" of available options is unique
--- fence/agents/lib/fencing.py.py | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py index 9172782..b9a2028 100644 --- a/fence/agents/lib/fencing.py.py +++ b/fence/agents/lib/fencing.py.py @@ -1196,6 +1196,7 @@ def _parse_input_stdin(avail_opt):
def _parse_input_cmdline(avail_opt): filtered_opts = {} + _verify_unique_getopt(avail_opt) (getopt_string, longopt_list) = _prepare_getopt_args(avail_opt)
try: @@ -1235,3 +1236,13 @@ def _get_opts_with_invalid_choices(options): if not options["--" + all_opt[opt]["longopt"]] in possible_values_upper: options_failed.append(opt) return options_failed + +def _verify_unique_getopt(avail_opt): + used_getopt = set() + + for opt in avail_opt: + getopt_value = all_opt[opt].get("getopt", "").rstrip(":") + if getopt_value and getopt_value in used_getopt: + fail_usage("Short getopt for %s (-%s) is not unique" % (opt, getopt_value)) + else: + used_getopt.add(getopt_value)