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

Re: [Cluster-devel] Fw: some fence_virsh, fene_apc patches for RHEL6 backports

On 12/19/2013 03:13 PM, Marek Grac wrote:
> On 12/18/2013 02:42 PM, Bogdan Dobrelya wrote:
>>> Based on your patch, I have sent a new patch to cluster-devel@ ; the
>>> main difference is that patch is based on current version (as there
>>> were several changes vs RHEL6). The other difference is that I have
>>> removed obtaining status of plug from list function because it can
>>> not work easily with UUID. Instead we call directly 'virsh domstate'
>>> ; on older systems there can be a problem with 'virsh --uuid --all'
>>> because '--uuid' is relatively new (yes, supported in RHEL6+) so I
>>> did not use this feature.
>> Hello. I believe, the device opt for "uuid" should be added as well
>> (see patch in attachment). Correct me, If I'm wrong...
> Hi,
> The 'uuid' is detected automatically (via standard python uuid library)
> so for user it enough to just enter it as --plug/-n. The
> options["--uuid"] is filled automatically in fencing library if uuid is
> detected. The same approach is used also in fence_vmware_soap.
> I know that documentation is the weak point and if everything will go as
> planned, I should spend most of the January by writing first drafts.
> m,
Hello. I've attached your uuid patch from master, backported to RHEL6
branch as well. I've tested it manually, by connecting to my libvirt
host using -U <uuid>, -n <name>, -o list options.
I hope we will see it for RHEL6 soon, uuid support is usefull feature.

Best regards,
Bogdan Dobrelya,
Researcher TechLead, Mirantis, Inc.
+38 (066) 051 07 53
Skype bogdando_at_yahoo.com
Irc #bogdando
38, Lenina ave.
Kharkov, Ukraine
bdobrelia mirantis com
>From 86203889378c7d728d89402de4a97e4ef55eddd4 Mon Sep 17 00:00:00 2001
From: Marek 'marx' Grac <mgrac redhat com>
Date: Mon, 16 Dec 2013 16:09:50 +0100
Subject: [PATCH] fence_virsh: Add UUID support for fence_virsh

UUID support for fence_virsh (libvirt) was added. The only function which has to be rewritted was
get_power_status as currently, there is no easy way how to print (name, uuid and state) via virsh.

This patch is based on one proposed by Bogdan Dobrelya for RHEL6.


Signed-off-by: Bogdan Dobrelya <bogdando mail ru>
 fence/agents/virsh/fence_virsh.py |   22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/fence/agents/virsh/fence_virsh.py b/fence/agents/virsh/fence_virsh.py
index 13099da..067d6ce 100644
--- a/fence/agents/virsh/fence_virsh.py
+++ b/fence/agents/virsh/fence_virsh.py
@@ -15,6 +15,9 @@ REDHAT_COPYRIGHT=""
+def get_name_or_uuid(options):
+	return options["-U"] if options.has_key("-U") else options["-n"]
 def get_outlets_status(conn, options):
 		conn.sendline("virsh list --all")
@@ -40,17 +43,20 @@ def get_outlets_status(conn, options):
 	return result
 def get_power_status(conn, options):
-	outlets=get_outlets_status(conn,options)
+	conn.sendline("virsh domstate %s" % (get_name_or_uuid(options)))
+	conn.log_expect(options, options["-c"], int(options["-Y"]))
+	for line in conn.before.splitlines():
+		if line.strip() in ["running", "blocked", "idle", "no state", "paused"]:
+			return "on"
+		if "error:" in line.strip():
+			fail_usage("Failed: You have to enter existing name/UUID of virtual machine!")
-        if (not (options["-n"] in outlets)):
-                fail_usage("Failed: You have to enter existing name of virtual machine!")
-        else:
-                return outlets[options["-n"]][1]
+	return "off"
 def set_power_status(conn, options):
-		conn.sendline("virsh %s "%(options["-o"] == "on" and "start" or "destroy")+options["-n"])
+                conn.sendline("virsh %s "%(options["-o"] == "on" and "start" or "destroy") + get_name_or_uuid(options))
 		conn.log_expect(options, options["-c"], int(options["-g"]))
@@ -63,7 +69,7 @@ def main():
 	device_opt = [  "help", "version", "agent", "quiet", "verbose", "debug",
 			"action", "ipaddr", "login", "passwd", "passwd_script",
 			"secure", "identity_file", "test", "port", "separator",
-			"inet4_only", "inet6_only", "ipport",
+			"inet4_only", "inet6_only", "ipport", "uuid",
 			"power_timeout", "shell_timeout", "login_timeout", "power_wait" ]

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