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

[Cluster-devel] Changes to fencing.py



Hi,

I sent an email a little while about a fencing agent script I was writing to handle Citrix XenServer virtual machine (and apparently XCP virtual machine). I think I am pretty close to finishing this off as I haven't made any code changes in a few weeks. Usually a good sign it's at least ready for others to test/play with.

I had to make the following changes to the fencing library. Feedback welcome.

Script source (fence_cxs_redhat.py) available at
http://code.google.com/p/fence-xenserver/downloads/list

Thanks,
Matt.

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):


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