Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Cluster Development (http://www.linux-archive.org/cluster-development/)
-   -   fence_vmware_soap: Support for 100+ VM in VMWare (http://www.linux-archive.org/cluster-development/617554-fence_vmware_soap-support-100-vm-vmware.html)

"Marek 'marx' Grac" 01-05-2012 03:38 PM

fence_vmware_soap: Support for 100+ VM in VMWare
 
In previous version, we did not try to get all results for VM. This
updated version fixes this issue by using proper SOAP API

Resolves: rhbz#735797
---
fence/agents/vmware_soap/fence_vmware_soap.py | 34 +++++++++++++++++--------
1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/fence/agents/vmware_soap/fence_vmware_soap.py b/fence/agents/vmware_soap/fence_vmware_soap.py
index f9344ff..9bebd08 100644
--- a/fence/agents/vmware_soap/fence_vmware_soap.py
+++ b/fence/agents/vmware_soap/fence_vmware_soap.py
@@ -39,6 +39,17 @@ def soap_login(options):
options["mo_SessionManager"] = mo_SessionManager
return conn

+def process_results(results, machines, uuid, mappingToUUID):
+ for m in results.objects:
+ 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"]
+
+ return (machines, uuid, mappingToUUID)
+
def get_power_status(conn, options):
mo_ViewManager = Property(options["ServiceContent"].viewManager.value)
mo_ViewManager._type = "ViewManager"
@@ -78,18 +89,19 @@ def get_power_status(conn, options):
except Exception, ex:
fail(EC_STATUS)

- machines = { }
- uuid = { }
- mappingToUUID = { }
+ (machines, uuid, mappingToUUID) = process_results(raw_machines, {}, {}, {})
+
+ # Probably need to loop over the ContinueRetreive if there are more results after 1 iteration.
+ while (hasattr(raw_machines, 'token') == True):
+ try:
+ raw_machines = conn.service.ContinueRetrievePropertiesEx(mo_Prope rtyCollector, raw_machines.token)
+ except Exception, ex:
+ fail(EC_STATUS)
+ (more_machines, more_uuid, more_mappingToUUID) = process_results(raw_machines, {}, {}, {})
+ machines.update(more_machines)
+ uuid.update(more_uuid)
+ mappingToUUID.update(more_mappingToUUID)

- for m in raw_machines.objects:
- 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"]
-
if ["list", "monitor"].count(options["-o"]) == 1:
return machines
else:
--
1.7.4.4


All times are GMT. The time now is 01:03 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.