Gitweb:
http://git.fedorahosted.org/git/?p=fence-agents.git;a=commitdiff;h=99975a...
Commit: 99975a5ffa708a17139cc1d61234c650395197b5
Parent: 29063ac151e702fa184c2e201dd41652ff329da8
Author: Marek 'marx' Grac <mgrac(a)redhat.com>
AuthorDate: Thu Sep 27 13:00:37 2012 +0200
Committer: Marek 'marx' Grac <mgrac(a)redhat.com>
CommitterDate: Mon Oct 8 10:36:04 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#769798
---
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