* [Cluster-devel] [PATCH] Updates to fencing.py to allow for virtual machine fencing.
@ 2011-03-23 10:59 mattjclark0407
2011-03-25 9:22 ` Marek Grac
0 siblings, 1 reply; 2+ messages in thread
From: mattjclark0407 @ 2011-03-23 10:59 UTC (permalink / raw)
To: cluster-devel.redhat.com
From: Matt Clark <mattjclark0407@hotmail.com>
Added all_opt parameters to aid in the fencing of virtual machines. Specifically this is for the fencing of machines through the XenAPI (Citrix XenServer or Xen Cloud Platform). New parameters are session_url, vm_name and uuid.
Updated logic to now check if either an IP address (-a) or a session URL (-s) is set.
Added a section to ensure that either a vm_name or uuid is specified. Because you can specify either, the "required" field in all_opt array can't be used and a separate explicit check is required.
---
fence/agents/lib/fencing.py.py | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/fence/agents/lib/fencing.py.py b/fence/agents/lib/fencing.py.py
index 4e5eb18..0ea2979 100644
--- a/fence/agents/lib/fencing.py.py
+++ b/fence/agents/lib/fencing.py.py
@@ -378,7 +378,28 @@ all_opt = {
"default" : "1",
"required" : "0",
"shortdesc" : "Count of attempts to retry power on",
- "order" : 201 }
+ "order" : 201 },
+ "session_url" : {
+ "getopt" : "s:",
+ "longopt" : "session-url",
+ "help" : "-s, --session-url URL to connect to XenServer on.",
+ "required" : "1",
+ "shortdesc" : "The URL of the XenServer host.",
+ "order" : 1},
+ "vm_name" : {
+ "getopt" : "n:",
+ "longopt" : "vm-name",
+ "help" : "-n, --vm-name Name of the VM to fence.",
+ "required" : "0",
+ "shortdesc" : "The name of the virual machine to fence.",
+ "order" : 1},
+ "uuid" : {
+ "getopt" : "U:",
+ "longopt" : "uuid",
+ "help" : "-U, --uuid UUID of the VM to fence.",
+ "required" : "0",
+ "shortdesc" : "The UUID of the virtual machine to fence.",
+ "order" : 1}
}
common_opt = [ "retry_on", "delay" ]
@@ -661,7 +682,7 @@ def check_input(device_opt, opt):
if (0 == options.has_key("-l")) and device_opt.count("login") and (device_opt.count("no_login") == 0):
fail_usage("Failed: You have to set login name")
- if 0 == options.has_key("-a"):
+ if 0 == options.has_key("-a") and 0 == options.has_key("-s"):
fail_usage("Failed: You have to enter fence address")
if (device_opt.count("no_password") == 0):
@@ -682,6 +703,10 @@ def check_input(device_opt, opt):
if (0 == ["list", "monitor"].count(options["-o"].lower())) and (0 == options.has_key("-n")) and (device_opt.count("port")):
fail_usage("Failed: You have to enter plug number")
+ if (0 == ["list", "monitor"].count(options["-o"].lower())) and device_opt.count("vm_name") and device_opt.count("uuid"):
+ if 0 == options.has_key("-n") and 0 == options.has_key("-U"):
+ fail_usage("Failed: You must specify either UUID or VM name")
+
if options.has_key("-S"):
options["-p"] = os.popen(options["-S"]).read().rstrip()
@@ -745,7 +770,7 @@ def fence_action(tn, options, set_power_fn, get_power_fn, get_outlet_list = None
## Process options that manipulate fencing device
#####
- if (options["-o"] == "list") and (0 == options["device_opt"].count("port")) and (0 == options["device_opt"].count("partition")):
+ if (options["-o"] == "list") and (0 == options["device_opt"].count("port")) and (0 == options["device_opt"].count("partition")) and (0 == options["device_opt"].count("uuid")):
print "N/A"
return
elif (options["-o"] == "list" and get_outlet_list == None):
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [PATCH] Updates to fencing.py to allow for virtual machine fencing.
2011-03-23 10:59 [Cluster-devel] [PATCH] Updates to fencing.py to allow for virtual machine fencing mattjclark0407
@ 2011-03-25 9:22 ` Marek Grac
0 siblings, 0 replies; 2+ messages in thread
From: Marek Grac @ 2011-03-25 9:22 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
On 03/23/2011 11:59 AM, mattjclark0407 at hotmail.com wrote:
> From: Matt Clark<mattjclark0407@hotmail.com>
>
> Added all_opt parameters to aid in the fencing of virtual machines. Specifically this is for the fencing of machines through the XenAPI (Citrix XenServer or Xen Cloud Platform). New parameters are session_url, vm_name and uuid.
>
session_url and uuid works for me.
vm_name should be replaced by existing port (-n) that is already used
for this purpose. I can fix this and push your patch to upstream if you
want.
> Updated logic to now check if either an IP address (-a) or a session URL (-s) is set.
>
good idea
> Added a section to ensure that either a vm_name or uuid is specified. Because you can specify either, the "required" field in all_opt array can't be used and a separate explicit check is required.
ok
m,
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-25 9:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-23 10:59 [Cluster-devel] [PATCH] Updates to fencing.py to allow for virtual machine fencing mattjclark0407
2011-03-25 9:22 ` Marek 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).