From: Marek 'marx' Grac <mgrac@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/2] fencing: UUID can be entered also as port number (-n / --plug / port)
Date: Tue, 13 Nov 2012 20:16:44 +0100 [thread overview]
Message-ID: <1352834205-14430-1-git-send-email-mgrac@redhat.com> (raw)
UUID is automatically detected using uuid library and we do not need
a special option/argument for it anymore. (--uuid is still supported)
---
fence/agents/lib/fencing.py.py | 23 +++++++++++++++++------
1 files changed, 17 insertions(+), 6 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 0041846..775bb4f 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -1,6 +1,6 @@
#!/usr/bin/python
-import sys, getopt, time, os
+import sys, getopt, time, os, uuid
import pexpect, re, atexit
import __main__
@@ -194,10 +194,10 @@ all_opt = {
"port" : {
"getopt" : "n:",
"longopt" : "plug",
- "help" : "-n, --plug=<id> Physical plug number on device or\n" +
- " name of virtual machine",
+ "help" : "-n, --plug=<id> Physical plug number on device, \n" +
+ " name of virtual machine or UUID",
"required" : "1",
- "shortdesc" : "Physical plug number or name of virtual machine",
+ "shortdesc" : "Physical plug number, name of virtual machine or UUID",
"order" : 1 },
"switch" : {
"getopt" : "s:",
@@ -697,6 +697,17 @@ def check_input(device_opt, opt):
options["--action"] = "on"
if options["--action"] == "disable":
options["--action"] = "off"
+
+ # UUID is now only alias for --plug; because we can detect it automatically
+ if options.has_key("--uuid"):
+ options["--plug"] == options["--uuid"]
+ del options["--uuid"]
+
+ ## automatic detection and set of valid UUID from --plug
+ try:
+ options["--uuid"] = str(uuid.UUID(options["--plug"]))
+ except ValueError:
+ pass
if (0 == options.has_key("--username")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
fail_usage("Failed: You have to set login name")
@@ -720,7 +731,7 @@ def check_input(device_opt, opt):
fail_usage("Failed: Identity file " + options["--identity-file"] + " does not exist")
if (0 == ["list", "monitor"].count(options["--action"].lower())) and \
- (0 == options.has_key("--plug") and 0 == options.has_key("--uuid")) and (device_opt.count("port")):
+ 0 == options.has_key("--plug") and device_opt.count("port"):
fail_usage("Failed: You have to enter plug number")
if options.has_key("--password-script"):
@@ -789,7 +800,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
#####
if (options["--action"] == "list") and \
0 == options["device_opt"].count("port") and 0 == options["device_opt"].count("partition") and \
- 0 == options["device_opt"].count("uuid") and 0 == options["device_opt"].count("module_name"):
+ 0 == options["device_opt"].count("module_name"):
print "N/A"
return
elif (options["--action"] == "list" and get_outlet_list == None):
--
1.7.7.6
next reply other threads:[~2012-11-13 19:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-13 19:16 Marek 'marx' Grac [this message]
2012-11-13 19:16 ` [Cluster-devel] [PATCH 2/2] fencing: Replace common options with more flexible mechanism Marek 'marx' Grac
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352834205-14430-1-git-send-email-mgrac@redhat.com \
--to=mgrac@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).