fence-agents: master - fence_vmware_soap: Faster fencing, fix crash on VM without valid UUID

Marek GrĂ¡c marx at fedoraproject.org
Thu Sep 27 11:05:09 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=582aa5f7f285e225928765fff50979154eafa138
Commit:        582aa5f7f285e225928765fff50979154eafa138
Parent:        37bf2c9eb75b3ed98edfec6991110af82a1c5efa
Author:        Marek 'marx' Grac <mgrac at redhat.com>
AuthorDate:    Thu Sep 27 13:00:37 2012 +0200
Committer:     Marek 'marx' Grac <mgrac at redhat.com>
CommitterDate: Thu Sep 27 13:00:37 2012 +0200

fence_vmware_soap: Faster fencing, fix crash on VM without valid UUID

Improve speed of fencing by removing requests for attributes that are not needed. This change is significant
when there are hundrens of VM on vSphere server. On the systems with <10 VM improvement is still about 20%.

This patch also fixes situation when there are VM which do not have valid UUID. This can happend when P2V (physical
to virtual machine process) failed.

Patch was proposed by: Rodrigo A B Freire

Resolves: rhbz#836654
---
 fence/agents/vmware_soap/fence_vmware_soap.py |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index 9bebd08..0da7f0d 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -44,9 +44,12 @@ def process_results(results, machines, uuid, mappingToUUID):
 		info = {}
 		for i in m.propSet:
 			info[i.name] = i.val
-		machines[info["name"]] = (info["config.uuid"], info["summary.runtime.powerState"])
-		uuid[info["config.uuid"]] = info["summary.runtime.powerState"]
-		mappingToUUID[m.obj.value] = info["config.uuid"]
+		# Prevent error KeyError: 'config.uuid' when reaching systems which P2V failed,
+		# since these systems don't have a valid UUID
+		if info.has_key("config.uuid"):
+			machines[info["name"]] = (info["config.uuid"], info["summary.runtime.powerState"])
+			uuid[info["config.uuid"]] = info["summary.runtime.powerState"]
+			mappingToUUID[m.obj.value] = info["config.uuid"]
 
 	return (machines, uuid, mappingToUUID)
 
@@ -77,7 +80,7 @@ def get_power_status(conn, options):
 
 	propSpec = conn.factory.create('ns0:PropertySpec')
 	propSpec.all = False
-	propSpec.pathSet = ["name", "summary.runtime.powerState", "config.uuid", "summary", "config", "capability", "network"]
+	propSpec.pathSet = ["name", "summary.runtime.powerState", "config.uuid"]
 	propSpec.type = "VirtualMachine"
 
 	propFilterSpec = conn.factory.create('ns0:PropertyFilterSpec')
@@ -101,6 +104,9 @@ def get_power_status(conn, options):
 		machines.update(more_machines)
 		uuid.update(more_uuid)
 		mappingToUUID.update(more_mappingToUUID)
+		# Do not run unnecessary SOAP requests
+		if options.has_key("-U") and options["-U"] in uuid:
+			break
 
 	if ["list", "monitor"].count(options["-o"]) == 1:
 		return machines


More information about the cluster-commits mailing list