cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [4/4] git commit: updated refs/heads/vmwaresdk-to-vijava to 67fc53a
Date Tue, 24 Sep 2013 03:54:45 GMT
Move away from the services model and fix all resulting errors


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/67fc53ab
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/67fc53ab
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/67fc53ab

Branch: refs/heads/vmwaresdk-to-vijava
Commit: 67fc53ab4b7a4b2f0d5ccb32f9cddb9e7fc5c5c1
Parents: 26d9aba
Author: Hugo Trippaers <htrippaers@schubergphilis.com>
Authored: Tue Sep 24 11:53:27 2013 +0800
Committer: Hugo Trippaers <htrippaers@schubergphilis.com>
Committed: Tue Sep 24 11:53:27 2013 +0800

----------------------------------------------------------------------
 .../vmware/manager/VmwareManagerImpl.java       |   5 +-
 .../vmware/resource/VmwareResource.java         |  38 +-
 .../com/cloud/hypervisor/vmware/mo/BaseMO.java  |  15 +-
 .../cloud/hypervisor/vmware/mo/ClusterMO.java   | 126 +++---
 .../vmware/mo/CustomFieldsManagerMO.java        |  15 +-
 .../hypervisor/vmware/mo/DatacenterMO.java      | 183 ++++-----
 .../cloud/hypervisor/vmware/mo/DatastoreMO.java |  70 ++--
 .../vmware/mo/DistributedVirtualSwitchMO.java   |  25 +-
 .../vmware/mo/HostDatastoreBrowserMO.java       |  15 +-
 .../vmware/mo/HostDatastoreSystemMO.java        |  29 +-
 .../vmware/mo/HostFirewallSystemMO.java         |  14 +-
 .../com/cloud/hypervisor/vmware/mo/HostMO.java  | 129 ++++---
 .../vmware/mo/HostNetworkSystemMO.java          |  19 +-
 .../vmware/mo/HostStorageSystemMO.java          |  13 +-
 .../hypervisor/vmware/mo/HttpNfcLeaseMO.java    |  14 +-
 .../vmware/mo/HypervisorHostHelper.java         |  62 +--
 .../vmware/mo/LicenseAssignmentManagerMO.java   |   7 +-
 .../cloud/hypervisor/vmware/mo/NetworkMO.java   |  11 +-
 .../hypervisor/vmware/mo/PerfManagerMO.java     |  66 +---
 .../com/cloud/hypervisor/vmware/mo/TaskMO.java  |  17 +-
 .../vmware/mo/VirtualDiskManagerMO.java         |  62 ++-
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 384 ++++++++++---------
 .../hypervisor/vmware/util/VmwareContext.java   |  34 +-
 23 files changed, 782 insertions(+), 571 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
index 0c06f60..a18fcd2 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java
@@ -42,6 +42,7 @@ import com.google.gson.Gson;
 import com.vmware.vim25.AboutInfo;
 import com.vmware.vim25.HostConnectSpec;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.ClusterComputeResource;
 
 import org.apache.cloudstack.api.command.admin.zone.AddVmwareDcCmd;
 import org.apache.cloudstack.api.command.admin.zone.ListVmwareDcsCmd;
@@ -454,8 +455,8 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
             hostSpec.setPassword(password);
             hostSpec.setHostName(host);
             hostSpec.setForce(true);		// forcely take over the host
-
-            ManagedObjectReference morTask = serviceContext.getService().addHost_Task(morCluster, hostSpec, true, null, null);
+            ClusterComputeResource cluster = new ClusterComputeResource(serviceContext.getServerConnection(), morCluster);
+            ManagedObjectReference morTask = cluster.addHost_Task(hostSpec, true, null, null).getMOR();
             boolean taskResult = vclient.waitForTask(morTask);
             if(!taskResult) {
                 s_logger.error("Unable to add host " + host + " to vSphere cluster due to " + TaskMO.getTaskFailureInfo(serviceContext, morTask));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
index 154ac34..652abb1 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
@@ -110,6 +110,10 @@ import com.vmware.vim25.VirtualMachineRelocateSpecDiskLocator;
 import com.vmware.vim25.VirtualMachineRuntimeInfo;
 import com.vmware.vim25.VirtualSCSISharing;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
+import com.vmware.vim25.mo.DistributedVirtualSwitch;
+import com.vmware.vim25.mo.DistributedVirtualSwitchManager;
+import com.vmware.vim25.mo.HostSystem;
+import com.vmware.vim25.mo.Task;
 
 import org.apache.cloudstack.engine.orchestration.VolumeOrchestrator;
 import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
@@ -3018,10 +3022,9 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         	if(s_logger.isDebugEnabled())
         		s_logger.debug("Nested Virtualization enabled in configuration, checking hypervisor capability");
             
-        	ManagedObjectReference hostMor = vmMo.getRunningHost().getMor();
-            ManagedObjectReference computeMor = context.getVimClient().getMoRefProp(hostMor, "parent");
-            ManagedObjectReference environmentBrowser = context.getVimClient().getMoRefProp(computeMor, "environmentBrowser");
-            HostCapability hostCapability = context.getService().queryTargetCapabilities(environmentBrowser, hostMor);
+            com.vmware.vim25.mo.VirtualMachine vm = (com.vmware.vim25.mo.VirtualMachine) vmMo.getManagedEntity();
+            HostSystem host = new HostSystem(context.getServerConnection(), vm.getRuntime().getHost());
+            HostCapability hostCapability = vm.getEnvironmentBrowser().queryTargetCapabilities(host);
             Boolean nestedHvSupported = hostCapability.getNestedHVSupported();
             if (nestedHvSupported == null) {
                 // nestedHvEnabled property is supported only since VMware 5.1. It's not defined for earlier versions.
@@ -3111,15 +3114,15 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
                     s_logger.debug("NIC " + nicTo.toString() + " is connected to dvSwitch " + dvSwitchUuid + " pg " + portGroupKey + " port " + portKey);
 
-                    ManagedObjectReference dvSwitchManager = vmMo.getContext().getVimClient().getServiceContent().getDvSwitchManager();
-                    ManagedObjectReference dvSwitch = vmMo.getContext().getVimClient().getService().queryDvsByUuid(dvSwitchManager, dvSwitchUuid);
+                    DistributedVirtualSwitchManager dvsManager = vmMo.getContext().getDistributedVirtualSwitchManager();
+                    DistributedVirtualSwitch dvSwitch = dvsManager.queryDvsByUuid(dvSwitchUuid);
 
                     // Get all ports
                     DistributedVirtualSwitchPortCriteria criteria = new DistributedVirtualSwitchPortCriteria();
                     criteria.setInside(true);
                     String[] portGroupKeys = (String[]) ArrayUtils.add(criteria.getPortgroupKey(), portGroupKey);
                     criteria.setPortgroupKey(portGroupKeys);
-                    DistributedVirtualPort[] dvPorts = vmMo.getContext().getVimClient().getService().fetchDVPorts(dvSwitch, criteria);
+                    DistributedVirtualPort[] dvPorts = dvSwitch.fetchDVPorts(criteria);
 
                     DistributedVirtualPort vmDvPort = null;
                     List<Integer> usedVlans = new ArrayList<Integer>();
@@ -3174,8 +3177,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                         dvPortConfigSpec.setKey(portKey);
                         List<DVPortConfigSpec> dvPortConfigSpecs = new ArrayList<DVPortConfigSpec>();
                         dvPortConfigSpecs.add(dvPortConfigSpec);
-                        ManagedObjectReference task = vmMo.getContext().getVimClient().getService().reconfigureDVPort_Task(dvSwitch, dvPortConfigSpecs.toArray(new DVPortConfigSpec[0]));
-                        if (!vmMo.getContext().getVimClient().waitForTask(task)) {
+                        Task task = dvSwitch.reconfigureDVPort_Task(dvPortConfigSpecs.toArray(new DVPortConfigSpec[0]));
+                        if (!vmMo.getContext().getVimClient().waitForTask(task.getMOR())) {
                             throw new Exception(
                                     "Failed to configure the dvSwitch port for nic "
                                             + nicTo.toString());
@@ -4352,8 +4355,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
 
         VmwareManager mgr = dcMo.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
 
-        List<ObjectContent> ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[] { "name", "parent" });
-        if (ocs != null && ocs.size() > 0) {
+        ObjectContent[] ocs = dcMo.getHostPropertiesOnDatacenterHostFolder(new String[] { "name", "parent" });
+        if (ocs != null && ocs.length > 0) {
             for (ObjectContent oc : ocs) {
                 HostMO hostMo = new HostMO(dcMo.getContext(), oc.getObj());
                 VmwareHypervisorHostNetworkSummary netSummary = hostMo.getHyperHostNetworkSummary(mgr.getManagementPortGroupByHost(hostMo));
@@ -4738,7 +4741,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         rescanAllHosts(lstHosts);
 
         HostStorageSystemMO hostStorageSystem = host.getHostStorageSystemMO();
-        List<HostScsiDisk> lstHostScsiDisks = hostDatastoreSystem.queryAvailableDisksForVmfs();
+        List<HostScsiDisk> lstHostScsiDisks = Arrays.asList(hostDatastoreSystem.queryAvailableDisksForVmfs()); 
 
         HostScsiDisk hostScsiDisk = getHostScsiDisk(hostStorageSystem.getStorageDeviceInfo().getScsiTopology(), lstHostScsiDisks, iqn);
 
@@ -4753,7 +4756,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
             throw new Exception("A relevant SCSI disk could not be located to use to create a datastore.");
         }
 
-        morDs = hostDatastoreSystem.createVmfsDatastore(datastoreName, hostScsiDisk);
+        morDs = hostDatastoreSystem.createVmfsDatastore(datastoreName, hostScsiDisk).getMOR();
 
         if (morDs != null) {
             rescanAllHosts(lstHosts);
@@ -5274,9 +5277,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         VmwareHypervisorHost hyperHost = getHyperHost(context);
         try {
             VirtualMachineMO vmMo = hyperHost.findVmOnHyperHost(cmd.getVmName());
+            com.vmware.vim25.mo.VirtualMachine vm = (com.vmware.vim25.mo.VirtualMachine) vmMo.getManagedEntity();
             if (vmMo != null) {
                 try {
-                    context.getService().unregisterVM(vmMo.getMor());
+                    vm.unregisterVM();
                     return new Answer(cmd, true, "unregister succeeded");
                 } catch(Exception e) {
                     s_logger.warn("We are not able to unregister VM " + VmwareHelper.getExceptionMessage(e));
@@ -6269,7 +6273,6 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
         VmwareHypervisorHost hyperHost = getHyperHost(getServiceContext());
         HashMap<String, VmStatsEntry> vmResponseMap = new HashMap<String, VmStatsEntry>();
         ManagedObjectReference perfMgr = getServiceContext().getServiceContent().getPerfManager();
-        VimPortType service = getServiceContext().getService();
         PerfCounterInfo rxPerfCounterInfo = null;
         PerfCounterInfo txPerfCounterInfo = null;
 
@@ -6331,7 +6334,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                     ArrayList<PerfMetricId> vmNetworkMetrics = new ArrayList<PerfMetricId>();
                     // get all the metrics from the available sample period
                     // FIXME: Is 0 the correct replacement of null here?
-                    PerfMetricId[] perfMetrics = service.queryAvailablePerfMetric(perfMgr, vmMor, null, null, 0);
+                    com.vmware.vim25.mo.VirtualMachine vm = (com.vmware.vim25.mo.VirtualMachine) vmMo.getManagedEntity();
+                    PerfMetricId[] perfMetrics = hyperHost.getContext().getPerformanceManager().queryAvailablePerfMetric(vm, null, null, 0);
                     if(perfMetrics != null) {
                         for(int index=0; index < perfMetrics.length; ++index) {
                             if ( ((rxPerfCounterInfo != null) && (perfMetrics[index].getCounterId() == rxPerfCounterInfo.getKey())) ||
@@ -6352,7 +6356,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
                         qSpec.setMetricId(availableMetricIds);
                         List<PerfQuerySpec> qSpecs = new ArrayList<PerfQuerySpec>();
                         qSpecs.add(qSpec);
-                        PerfEntityMetricBase[] values = service.queryPerf(perfMgr, qSpecs.toArray(new PerfQuerySpec[0]));
+                        PerfEntityMetricBase[] values = hyperHost.getContext().getPerformanceManager().queryPerf(qSpecs.toArray(new PerfQuerySpec[0]));
 
                         for(int i=0; i<values.length; ++i) {
                             PerfSampleInfo[]  infos = ((PerfEntityMetric) values[i]).getSampleInfo();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/BaseMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/BaseMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/BaseMO.java
index d5d6fee..dd3a438 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/BaseMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/BaseMO.java
@@ -19,9 +19,12 @@ package com.cloud.hypervisor.vmware.mo;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.CustomFieldDef;
 import com.vmware.vim25.CustomFieldStringValue;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.ManagedEntity;
+import com.vmware.vim25.mo.Task;
 
 public class BaseMO {
     private static final Logger s_logger = Logger.getLogger(BaseMO.class);
@@ -70,7 +73,8 @@ public class BaseMO {
 	}
 
 	public boolean destroy() throws Exception {
-        ManagedObjectReference morTask = _context.getService().destroy_Task(_mor);
+	    Task task = getManagedEntity().destroy_Task();
+	    ManagedObjectReference morTask = task.getMOR();
 
         boolean result = _context.getVimClient().waitForTask(morTask);
         if(result) {
@@ -83,11 +87,12 @@ public class BaseMO {
 	}
 
 	public void reload() throws Exception {
-	    _context.getService().reload(_mor);
+	    getManagedEntity().reload();
 	}
 
 	public boolean rename(String newName) throws Exception {
-	    ManagedObjectReference morTask = _context.getService().rename_Task(_mor, newName);
+	    Task task = getManagedEntity().rename_Task(newName);
+	    ManagedObjectReference morTask = task.getMOR();
 
         boolean result = _context.getVimClient().waitForTask(morTask);
         if(result) {
@@ -146,4 +151,8 @@ public class BaseMO {
 
 		return cfmMo.getCustomFieldKey(morType, fieldName);
 	}
+	
+	public ManagedEntity getManagedEntity() {
+	    return new ManagedEntity(_context.getServerConnection(), _mor);
+	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
index bbd9e79..1d4c789 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
@@ -46,6 +46,11 @@ import com.vmware.vim25.PropertyFilterSpec;
 import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.TraversalSpec;
 import com.vmware.vim25.VirtualMachineConfigSpec;
+import com.vmware.vim25.mo.ClusterComputeResource;
+import com.vmware.vim25.mo.Folder;
+import com.vmware.vim25.mo.PropertyCollector;
+import com.vmware.vim25.mo.ResourcePool;
+import com.vmware.vim25.mo.Task;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.Pair;
@@ -58,13 +63,16 @@ import java.util.Arrays;
 //
 public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
     private static final Logger s_logger = Logger.getLogger(ClusterMO.class);
+    private ClusterComputeResource _clusterComputeResource;
 
 	public ClusterMO(VmwareContext context, ManagedObjectReference morCluster) {
 		super(context, morCluster);
+		_clusterComputeResource = (ClusterComputeResource) this.getManagedEntity();
 	}
 
 	public ClusterMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_clusterComputeResource = (ClusterComputeResource) this.getManagedEntity();
 	}
 
 	@Override
@@ -125,11 +133,11 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public ObjectContent[] getVmPropertiesOnHyperHost(String[] propertyPaths) throws Exception {
 		if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
+			s_logger.trace("vCenter API trace - retrieveProperties() for VM properties. target MOR: " + _mor.getVal() + ", properties: " + new Gson().toJson(propertyPaths));
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("VirtualMachine");
-		pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+		pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec host2VmFolderTraversal = new TraversalSpec();
 	    host2VmFolderTraversal.setType("HostSystem");
@@ -140,34 +148,35 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	    cluster2HostFolderTraversal.setType("ClusterComputeResource");
 	    cluster2HostFolderTraversal.setPath("host");
 	    cluster2HostFolderTraversal.setName("cluster2HostFolderTraversal");
-	    cluster2HostFolderTraversal.getSelectSet().add(host2VmFolderTraversal);
+	    cluster2HostFolderTraversal.setSelectSet(new TraversalSpec[] { host2VmFolderTraversal });
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(getMor());
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(cluster2HostFolderTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { cluster2HostFolderTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
-
-	    List<ObjectContent> properties = _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
+	    
+	    PropertyCollector pc = _context.getPropertyCollector();
+	    ObjectContent[] properties = pc.retrieveProperties(pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - retrieveProperties() done");
-	    return properties.toArray(new ObjectContent[properties.size()]);
+	    return properties;
 	}
 
 	@Override
 	public ObjectContent[] getDatastorePropertiesOnHyperHost(String[] propertyPaths) throws Exception {
 		if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
+			s_logger.trace("vCenter API trace - retrieveProperties() on Datastore properties. target MOR: " + _mor.getVal() + ", properties: " + new Gson().toJson(propertyPaths));
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("Datastore");
-        pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+        pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec cluster2DatastoreTraversal = new TraversalSpec();
 	    cluster2DatastoreTraversal.setType("ClusterComputeResource");
@@ -177,29 +186,29 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(cluster2DatastoreTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { cluster2DatastoreTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    List<ObjectContent> properties = _context.getService().retrieveProperties(
-	    	_context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+        ObjectContent[] properties = pc.retrieveProperties(pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - retrieveProperties() done");
-	    return properties.toArray(new ObjectContent[properties.size()]);
+	    return properties;
 	}
 
 	private ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
 		if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getValue() + ", properties: " + new Gson().toJson(propertyPaths));
+			s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getVal() + ", properties: " + new Gson().toJson(propertyPaths));
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("HostSystem");
-        pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+        pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec cluster2HostTraversal = new TraversalSpec();
 	    cluster2HostTraversal.setType("ClusterComputeResource");
@@ -209,34 +218,36 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(cluster2HostTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { cluster2HostTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });;
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 
         List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
         pfSpecArr.add(pfSpec);
 
-        List<ObjectContent> properties = _context.getService().retrieveProperties(
-            _context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+        ObjectContent[] properties = pc.retrieveProperties(pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - retrieveProperties() done");
-	    return properties.toArray(new ObjectContent[properties.size()]);
+	    return properties;
 	}
 
 	@Override
 	public boolean createVm(VirtualMachineConfigSpec vmSpec) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - createVM_Task(). target MOR: " + _mor.getValue() + ", VirtualMachineConfigSpec: " + new Gson().toJson(vmSpec));
+			s_logger.trace("vCenter API trace - createVM_Task(). target MOR: " + _mor.getVal() + ", VirtualMachineConfigSpec: " + new Gson().toJson(vmSpec));
 
 		assert(vmSpec != null);
 		DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
         ManagedObjectReference morPool = getHyperHostOwnerResourcePool();
 
-	    ManagedObjectReference morTask = _context.getService().createVMTask(
-	    	dcMo.getVmFolder(), vmSpec, morPool, null);
+        Folder vmFolder = new Folder(_context.getServerConnection(), dcMo.getVmFolder());
+        ResourcePool resourcePool = new ResourcePool(_context.getServerConnection(), morPool);
+        Task task = vmFolder.createVM_Task(vmSpec, resourcePool, null);
+	    ManagedObjectReference morTask = task.getMOR();
 		boolean result = _context.getVimClient().waitForTask(morTask);
 
 		if(result) {
@@ -257,14 +268,14 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName
-				+ ", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);
+			s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getVal() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName
+				+ ", datastore: " + dsMo.getMor().getVal() + ", diskOption: " + diskOption);
 
 		ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
 		assert(morRp != null);
 
 		if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - importVmFromOVF(). resource pool: " + morRp.getValue());
+			s_logger.trace("vCenter API trace - importVmFromOVF(). resource pool: " + morRp.getVal());
 
 		HypervisorHostHelper.importVmFromOVF(this, ovfFilePath, vmName, dsMo, diskOption, morRp, null);
 
@@ -277,9 +288,9 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getValue() + ", vmName: " + vmName + ", cpuCount: " + cpuCount
+			s_logger.trace("vCenter API trace - createBlankVm(). target MOR: " + _mor.getVal() + ", vmName: " + vmName + ", cpuCount: " + cpuCount
 				+ ", cpuSpeedMhz: " + cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB
-				+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
+				+ ", guestOS: " + guestOsIdentifier + ", datastore: " + morDs.getVal() + ", snapshotDirToParent: " + snapshotDirToParent);
 
 		boolean result = HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse,
 			memoryMB, memoryReserveMB, guestOsIdentifier, morDs, snapshotDirToParent);
@@ -295,7 +306,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		int poolHostPort, String poolPath, String poolUuid) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress
+			s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getVal() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress
 				+ ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
 
 		ManagedObjectReference morDs = null;
@@ -309,7 +320,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 					morDsFirst = morDs;
 
 				// assume datastore is in scope of datacenter
-				assert(morDsFirst.getValue().equals(morDs.getValue()));
+				assert(morDsFirst.getVal().equals(morDs.getVal()));
 			}
 		}
 
@@ -331,7 +342,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public void unmountDatastore(String poolUuid) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
+			s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getVal() + ", poolUuid: " + poolUuid);
 
 		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
 		if(hosts != null && hosts.size() > 0) {
@@ -349,7 +360,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	public ManagedObjectReference findDatastore(String poolUuid) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - findDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
+			s_logger.trace("vCenter API trace - findDatastore(). target MOR: " + _mor.getVal() + ", poolUuid: " + poolUuid);
 
 		CustomFieldsManagerMO cfmMo = new CustomFieldsManagerMO(_context,
 				_context.getServiceContent().getCustomFieldsManager());
@@ -359,11 +370,11 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] {"name", String.format("value[%d]", key)});
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
-				if(oc.getPropSet().get(0).getVal().equals(poolUuid))
+				if(oc.getPropSet()[0].getVal().equals(poolUuid))
 					return oc.getObj();
 
-				if(oc.getPropSet().size() > 1) {
-					DynamicProperty prop = oc.getPropSet().get(1);
+				if(oc.getPropSet().length > 1) {
+					DynamicProperty prop = oc.getPropSet()[1];
 					if(prop != null && prop.getVal() != null) {
 						if(prop.getVal() instanceof CustomFieldStringValue) {
 							String val = ((CustomFieldStringValue)prop.getVal()).getValue();
@@ -387,12 +398,12 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - findDatastoreByExportPath(). target MOR: " + _mor.getValue() + ", exportPath: " + exportPath);
+			s_logger.trace("vCenter API trace - findDatastoreByExportPath(). target MOR: " + _mor.getVal() + ", exportPath: " + exportPath);
 
 		ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] {"info"});
 		if(ocs != null && ocs.length > 0) {
 			for(ObjectContent oc : ocs) {
-				DatastoreInfo dsInfo = (DatastoreInfo)oc.getPropSet().get(0).getVal();
+				DatastoreInfo dsInfo = (DatastoreInfo)oc.getPropSet()[0].getVal();
 				if(dsInfo != null && dsInfo instanceof NasDatastoreInfo) {
 					NasDatastoreInfo info = (NasDatastoreInfo)dsInfo;
 					if(info != null) {
@@ -420,13 +431,13 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public ManagedObjectReference findMigrationTarget(VirtualMachineMO vmMo) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - findMigrationTarget(). target MOR: " + _mor.getValue() + ", vm: " + vmMo.getName());
+			s_logger.trace("vCenter API trace - findMigrationTarget(). target MOR: " + _mor.getVal() + ", vm: " + vmMo.getName());
 
-		List<ClusterHostRecommendation> candidates = recommendHostsForVm(vmMo);
-		if(candidates != null && candidates.size() > 0) {
+		ClusterHostRecommendation[] candidates = recommendHostsForVm(vmMo);
+		if(candidates != null && candidates.length > 0) {
 		    if(s_logger.isTraceEnabled())
 				s_logger.trace("vCenter API trace - findMigrationTarget() done(successfully)");
-			return candidates.get(0).getHost();
+			return candidates[0].getHost();
 		}
 
 	    if(s_logger.isTraceEnabled())
@@ -439,9 +450,9 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		ObjectContent[] ocs = getHostPropertiesOnCluster(new String[] {"runtime"});
 		if(ocs != null && ocs.length > 0) {
 			for(ObjectContent oc : ocs) {
-				HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)oc.getPropSet().get(0).getVal();
+				HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)oc.getPropSet()[0].getVal();
 				// as long as we have one host connected, we assume the cluster is up
-				if(runtimeInfo.getConnectionState() == HostSystemConnectionState.CONNECTED)
+				if(runtimeInfo.getConnectionState() == HostSystemConnectionState.connected)
 					return true;
 			}
 		}
@@ -453,7 +464,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		ObjectContent[] ocs = getHostPropertiesOnCluster(new String[] {"config.network.routeTableInfo.ipRoute"});
 		if(ocs != null && ocs.length > 0) {
 			for(ObjectContent oc : ocs) {
-				ArrayOfHostIpRouteEntry entries = (ArrayOfHostIpRouteEntry)oc.getPropSet().get(0).getVal();
+				ArrayOfHostIpRouteEntry entries = (ArrayOfHostIpRouteEntry)oc.getPropSet()[0].getVal();
 				if(entries != null) {
 					for(HostIpRouteEntry entry : entries.getHostIpRouteEntry()) {
 						if(entry.getNetwork().equalsIgnoreCase("0.0.0.0"))
@@ -469,7 +480,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public VmwareHypervisorHostResourceSummary getHyperHostResourceSummary() throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - getHyperHostResourceSummary(). target MOR: " + _mor.getValue());
+			s_logger.trace("vCenter API trace - getHyperHostResourceSummary(). target MOR: " + _mor.getVal());
 
 		VmwareHypervisorHostResourceSummary summary = new VmwareHypervisorHostResourceSummary();
 
@@ -501,7 +512,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String esxServiceConsolePort) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + esxServiceConsolePort);
+			s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getVal() + ", mgmtPortgroup: " + esxServiceConsolePort);
 
 		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
 		if(hosts != null && hosts.size() > 0) {
@@ -520,7 +531,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public ComputeResourceSummary getHyperHostHardwareSummary() throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - getHyperHostHardwareSummary(). target MOR: " + _mor.getValue());
+			s_logger.trace("vCenter API trace - getHyperHostHardwareSummary(). target MOR: " + _mor.getVal());
 
 		ClusterComputeResourceSummary hardwareSummary = (ClusterComputeResourceSummary)
 			_context.getVimClient().getDynamicProperty(_mor, "summary");
@@ -530,9 +541,10 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		return hardwareSummary;
 	}
 
-	public List<ClusterHostRecommendation> recommendHostsForVm(VirtualMachineMO vmMo) throws Exception {
-		return _context.getService().recommendHostsForVm(_mor, vmMo.getMor(),
-			getHyperHostOwnerResourcePool());
+	public ClusterHostRecommendation[] recommendHostsForVm(VirtualMachineMO vmMo) throws Exception {
+	    ClusterComputeResource cluster = new ClusterComputeResource(_context.getServerConnection(), _mor);
+	    
+		return cluster.recommendHostsForVm(vmMo.getVirtualMachine(), cluster.getResourcePool());
 	}
 
 	public List<Pair<ManagedObjectReference, String>> getClusterHosts() throws Exception {
@@ -542,7 +554,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
 				ManagedObjectReference morHost = oc.getObj();
-				String name = (String)oc.getPropSet().get(0).getVal();
+				String name = (String)oc.getPropSet()[0].getVal();
 
 				hosts.add(new Pair<ManagedObjectReference, String>(morHost, name));
 			}
@@ -558,7 +570,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
         HashMap<String, Integer> portInfo = new HashMap<String, Integer>();
     	if(ocs != null && ocs.length > 0) {
     		for(ObjectContent oc : ocs) {
-		        List<DynamicProperty> objProps = oc.getPropSet();
+		        DynamicProperty[] objProps = oc.getPropSet();
 		        if(objProps != null) {
 		        	String name = null;
 		        	String value = null;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
index 3082a71..6f28f50 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
@@ -19,35 +19,42 @@ package com.cloud.hypervisor.vmware.mo;
 import java.util.List;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.CustomFieldDef;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.PrivilegePolicyDef;
+import com.vmware.vim25.mo.CustomFieldsManager;
+import com.vmware.vim25.mo.ManagedEntity;
 
 public class CustomFieldsManagerMO extends BaseMO {
+    private CustomFieldsManager _customFieldsManager;
 
 	public CustomFieldsManagerMO(VmwareContext context, ManagedObjectReference mor) {
 		super(context, mor);
+		_customFieldsManager = new CustomFieldsManager(context.getServerConnection(), mor); 
 	}
 
 	public CustomFieldsManagerMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_customFieldsManager = new CustomFieldsManager(context.getServerConnection(), _mor);
 	}
 
 	public CustomFieldDef addCustomerFieldDef(String fieldName, String morType,
 		PrivilegePolicyDef fieldDefPolicy, PrivilegePolicyDef fieldPolicy) throws Exception {
-		return _context.getService().addCustomFieldDef(getMor(), fieldName, morType, fieldDefPolicy, fieldPolicy);
+		return _customFieldsManager.addCustomFieldDef(fieldName, morType, fieldDefPolicy, fieldPolicy);
 	}
 
 	public void removeCustomFieldDef(int key) throws Exception {
-		_context.getService().removeCustomFieldDef(getMor(), key);
+		_customFieldsManager.removeCustomFieldDef(key);
 	}
 
 	public void renameCustomFieldDef(int key, String name) throws Exception {
-		_context.getService().renameCustomFieldDef(getMor(), key, name);
+		_customFieldsManager.renameCustomFieldDef(key, name);
 	}
 
 	public void setField(ManagedObjectReference morEntity, int key, String value) throws Exception {
-		_context.getService().setField(getMor(), morEntity, key, value);
+	    ManagedEntity managedEntity = new ManagedEntity(_context.getServerConnection(), morEntity);
+		_customFieldsManager.setField(managedEntity, key, value);
 	}
 
 	public List<CustomFieldDef> getFields() throws Exception {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
index 1844b6a..ea71b6a 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatacenterMO.java
@@ -22,6 +22,7 @@ import java.util.List;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.Pair;
+
 import com.vmware.vim25.CustomFieldStringValue;
 import com.vmware.vim25.DVPortgroupConfigInfo;
 import com.vmware.vim25.DistributedVirtualSwitchPortConnection;
@@ -34,16 +35,25 @@ import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.SelectionSpec;
 import com.vmware.vim25.TraversalSpec;
 import com.vmware.vim25.VirtualEthernetCardDistributedVirtualPortBackingInfo;
+import com.vmware.vim25.mo.Datacenter;
+import com.vmware.vim25.mo.Folder;
+import com.vmware.vim25.mo.HostSystem;
+import com.vmware.vim25.mo.PropertyCollector;
+import com.vmware.vim25.mo.Task;
+
 import java.util.Arrays;
 
 public class DatacenterMO extends BaseMO {
+    protected Datacenter _datacenter;
 
 	public DatacenterMO(VmwareContext context, ManagedObjectReference morDc) {
 		super(context, morDc);
+		_datacenter = (Datacenter) this.getManagedEntity();
 	}
 
 	public DatacenterMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_datacenter =  (Datacenter) this.getManagedEntity();
 	}
 
 	public DatacenterMO(VmwareContext context, String dcName) throws Exception {
@@ -61,16 +71,14 @@ public class DatacenterMO extends BaseMO {
 	public void registerTemplate(ManagedObjectReference morHost, String datastoreName,
 		String templateName, String templateFileName) throws Exception {
 
-
-		ManagedObjectReference morFolder = (ManagedObjectReference)_context.getVimClient().getDynamicProperty(
-			_mor, "vmFolder");
-		assert(morFolder != null);
-
-		ManagedObjectReference morTask = _context.getService().registerVMTask(
-    		 morFolder,
-    		 String.format("[%s] %s/%s", datastoreName, templateName, templateFileName),
-    		 templateName, true,
-    		 null, morHost);
+		Folder vmFolder = _datacenter.getVmFolder();
+		String path = String.format("[%s] %s/%s", datastoreName, templateName, templateFileName);
+		HostSystem host = null;
+		if (morHost != null) {
+		    host = new HostSystem(_context.getServerConnection(), morHost);
+		}
+		Task task = vmFolder.registerVM_Task(path, templateName, true, null, host);
+		ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if (!result) {
@@ -81,10 +89,10 @@ public class DatacenterMO extends BaseMO {
 	}
 
 	public VirtualMachineMO findVm(String vmName) throws Exception {
-		List<ObjectContent> ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
-		if(ocs != null && ocs.size() > 0) {
+		ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
+		if(ocs != null && ocs.length > 0) {
 			for(ObjectContent oc : ocs) {
-				List<DynamicProperty> props = oc.getPropSet();
+				DynamicProperty[] props = oc.getPropSet();
 				if(props != null) {
 					for(DynamicProperty prop : props) {
 						if(prop.getVal().toString().equals(vmName))
@@ -104,10 +112,10 @@ public class DatacenterMO extends BaseMO {
 
 		List<VirtualMachineMO> list = new ArrayList<VirtualMachineMO>();
 
-		List<ObjectContent> ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name",  String.format("value[%d]", key)});
-		if(ocs != null && ocs.size() > 0) {
+		ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name",  String.format("value[%d]", key)});
+		if(ocs != null && ocs.length > 0) {
 			for(ObjectContent oc : ocs) {
-				List<DynamicProperty> props = oc.getPropSet();
+				DynamicProperty[] props = oc.getPropSet();
 				if(props != null) {
 					for(DynamicProperty prop : props) {
 						if(prop.getVal() != null) {
@@ -134,10 +142,10 @@ public class DatacenterMO extends BaseMO {
 	public List<Pair<ManagedObjectReference, String>> getAllVmsOnDatacenter() throws Exception {
 	    List<Pair<ManagedObjectReference, String>> vms = new ArrayList<Pair<ManagedObjectReference, String>>();
 
-	    List<ObjectContent> ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
+	    ObjectContent[] ocs = getVmPropertiesOnDatacenterVmFolder(new String[] { "name" });
 	    if(ocs != null) {
 	        for(ObjectContent oc : ocs) {
-	            String vmName = oc.getPropSet().get(0).getVal().toString();
+	            String vmName = oc.getPropSet()[0].getVal().toString();
 	            vms.add(new Pair<ManagedObjectReference, String>(oc.getObj(), vmName));
 	        }
 	    }
@@ -148,10 +156,10 @@ public class DatacenterMO extends BaseMO {
 	public ManagedObjectReference findDatastore(String name) throws Exception {
 		assert(name != null);
 
-		List<ObjectContent> ocs = getDatastorePropertiesOnDatacenter(new String[] { "name" });
+		ObjectContent[] ocs = getDatastorePropertiesOnDatacenter(new String[] { "name" });
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
-				if(oc.getPropSet().get(0).getVal().toString().equals(name)) {
+				if(oc.getPropSet()[0].getVal().toString().equals(name)) {
 					return oc.getObj();
 				}
 			}
@@ -160,11 +168,11 @@ public class DatacenterMO extends BaseMO {
 	}
 
 	public ManagedObjectReference findHost(String name) throws Exception {
-		List<ObjectContent> ocs= getHostPropertiesOnDatacenterHostFolder(new String[] { "name" });
+		ObjectContent[] ocs= getHostPropertiesOnDatacenterHostFolder(new String[] { "name" });
 
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
-				if(oc.getPropSet().get(0).getVal().toString().equals(name)) {
+				if(oc.getPropSet()[0].getVal().toString().equals(name)) {
 					return oc.getObj();
 				}
 			}
@@ -176,10 +184,10 @@ public class DatacenterMO extends BaseMO {
 		return (ManagedObjectReference)_context.getVimClient().getDynamicProperty(_mor, "vmFolder");
 	}
 
-	public List<ObjectContent> getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
+	public ObjectContent[] getHostPropertiesOnDatacenterHostFolder(String[] propertyPaths) throws Exception {
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("HostSystem");
-		pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+		pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec computeResource2HostTraversal = new TraversalSpec();
 	    computeResource2HostTraversal.setType("ComputeResource");
@@ -193,35 +201,35 @@ public class DatacenterMO extends BaseMO {
 	    folder2childEntity.setType("Folder");
 	    folder2childEntity.setPath("childEntity");
 	    folder2childEntity.setName(recurseFolders.getName());
-	    folder2childEntity.getSelectSet().add(recurseFolders);
-        folder2childEntity.getSelectSet().add(computeResource2HostTraversal);
+	    folder2childEntity.setSelectSet( new SelectionSpec[] { recurseFolders, computeResource2HostTraversal });
 
 	    TraversalSpec dc2HostFolderTraversal = new TraversalSpec();
 	    dc2HostFolderTraversal.setType("Datacenter");
 	    dc2HostFolderTraversal.setPath("hostFolder");
 	    dc2HostFolderTraversal.setName("dc2HostFolderTraversal");
-	    dc2HostFolderTraversal.getSelectSet().add(folder2childEntity);
+	    dc2HostFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity });
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(dc2HostFolderTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { dc2HostFolderTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
+	    PropertyCollector pc = _context.getPropertyCollector();
+	    return pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	}
 
-	public List<ObjectContent> getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
+	public ObjectContent[] getDatastorePropertiesOnDatacenter(String[] propertyPaths) throws Exception {
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("Datastore");
-		pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+		pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec dc2DatastoreTraversal = new TraversalSpec();
 	    dc2DatastoreTraversal.setType("Datacenter");
@@ -231,22 +239,22 @@ public class DatacenterMO extends BaseMO {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(dc2DatastoreTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { dc2DatastoreTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
-
+        PropertyCollector pc = _context.getPropertyCollector();
+        return pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 	}
 
-	public List<ObjectContent> getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws Exception {
+	public ObjectContent[] getVmPropertiesOnDatacenterVmFolder(String[] propertyPaths) throws Exception {
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("VirtualMachine");
-		pSpec.getPathSet().addAll(Arrays.asList(propertyPaths));
+		pSpec.setPathSet(propertyPaths);
 
 	    TraversalSpec dc2VmFolderTraversal = new TraversalSpec();
 	    dc2VmFolderTraversal.setType("Datacenter");
@@ -261,29 +269,30 @@ public class DatacenterMO extends BaseMO {
 	    folder2childEntity.setType("Folder");
 	    folder2childEntity.setPath("childEntity");
 	    folder2childEntity.setName(recurseFolders.getName());
-	    folder2childEntity.getSelectSet().add(recurseFolders);
-	    dc2VmFolderTraversal.getSelectSet().add(folder2childEntity);
+	    folder2childEntity.setSelectSet(new SelectionSpec[] { recurseFolders });
+	    dc2VmFolderTraversal.setSelectSet(new SelectionSpec[] { folder2childEntity });
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(dc2VmFolderTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { dc2VmFolderTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
-
-	    return _context.getService().retrieveProperties(_context.getPropertyCollector(), pfSpecArr);
-	}
+	       
+	    PropertyCollector pc = _context.getPropertyCollector();
+	    return pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
+}
 
 	public static Pair<DatacenterMO, String> getOwnerDatacenter(VmwareContext context,
 		ManagedObjectReference morEntity) throws Exception {
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("Datacenter");
-		pSpec.getPathSet().add("name");
+		pSpec.setPathSet(new String[] { "name" });
 
 	    TraversalSpec entityParentTraversal = new TraversalSpec();
 	    entityParentTraversal.setType("ManagedEntity");
@@ -291,36 +300,36 @@ public class DatacenterMO extends BaseMO {
 	    entityParentTraversal.setName("entityParentTraversal");
 	    SelectionSpec selSpec = new SelectionSpec();
 	    selSpec.setName("entityParentTraversal");
-	    entityParentTraversal.getSelectSet().add(selSpec);
+	    entityParentTraversal.setSelectSet(new SelectionSpec[] { selSpec });
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(morEntity);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(entityParentTraversal);
+	    oSpec.setSelectSet(new SelectionSpec[] { entityParentTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    List<ObjectContent> ocs = context.getService().retrieveProperties(
-	    	context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = context.getPropertyCollector();
+        ObjectContent[] ocs = pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
-	    assert(ocs != null && ocs.size() > 0);
-	    assert(ocs.get(0).getObj() != null);
-	    assert(ocs.get(0).getPropSet().get(0) != null);
-	    assert(ocs.get(0).getPropSet().get(0).getVal() != null);
+	    assert(ocs != null && ocs.length > 0);
+	    assert(ocs[0].getObj() != null);
+	    assert(ocs[0].getPropSet()[0] != null);
+	    assert(ocs[0].getPropSet()[0].getVal() != null);
 
-	    String dcName = ocs.get(0).getPropSet().get(0).getVal().toString();
-	    return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs.get(0).getObj()), dcName);
+	    String dcName = ocs[0].getPropSet()[0].getVal().toString();
+	    return new Pair<DatacenterMO, String>(new DatacenterMO(context, ocs[0].getObj()), dcName);
 	}
 
 
 	public ManagedObjectReference getDvPortGroupMor(String dvPortGroupName) throws Exception {
     		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("DistributedVirtualPortgroup");
-		pSpec.getPathSet().add("name");
+		pSpec.setPathSet(new String[] { "name" });
 
 		TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
 		datacenter2DvPortGroupTraversal.setType("Datacenter");
@@ -330,20 +339,20 @@ public class DatacenterMO extends BaseMO {
 		ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(datacenter2DvPortGroupTraversal);
+	    oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    List<ObjectContent> ocs = _context.getService().retrieveProperties(
-	    	_context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+        ObjectContent[] ocs = pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	    if(ocs != null) {
 	    	for(ObjectContent oc : ocs) {
-	    		List<DynamicProperty> props = oc.getPropSet();
+	    		DynamicProperty[] props = oc.getPropSet();
 	    		if(props != null) {
 	    			for(DynamicProperty prop : props) {
 	    				if(prop.getVal().equals(dvPortGroupName))
@@ -367,8 +376,7 @@ public class DatacenterMO extends BaseMO {
 		String nameProperty = null;
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("DistributedVirtualPortgroup");
-		pSpec.getPathSet().add("name");
-		pSpec.getPathSet().add("config");
+		pSpec.setPathSet(new String[] { "name", "config" });
 
 	    TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
 	    datacenter2DvPortGroupTraversal.setType("Datacenter");
@@ -378,22 +386,22 @@ public class DatacenterMO extends BaseMO {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(datacenter2DvPortGroupTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { datacenter2DvPortGroupTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
 	    List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
 	    pfSpecArr.add(pfSpec);
 
-	    List<ObjectContent> ocs = _context.getService().retrieveProperties(
-	    	_context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+        ObjectContent[] ocs = pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
 	    if(ocs != null) {
 	    	for(ObjectContent oc : ocs) {
-	    		List<DynamicProperty> props = oc.getPropSet();
+	    		DynamicProperty[] props = oc.getPropSet();
 	    		if(props != null) {
-	    			assert(props.size() == 2);
+	    			assert(props.length == 2);
 	    			for(DynamicProperty prop : props) {
 	    				if(prop.getName().equals("config")) {
 	    					  configSpec = (DVPortgroupConfigInfo) prop.getVal();
@@ -416,8 +424,7 @@ public class DatacenterMO extends BaseMO {
         ManagedObjectReference dvSwitchMor = null;
         PropertySpec pSpec = new PropertySpec();
         pSpec.setType("DistributedVirtualPortgroup");
-        pSpec.getPathSet().add("key");
-        pSpec.getPathSet().add("config.distributedVirtualSwitch");
+        pSpec.setPathSet(new String[] { "key", "config.distributedVirtualSwitch" });
 
         TraversalSpec datacenter2DvPortGroupTraversal = new TraversalSpec();
         datacenter2DvPortGroupTraversal.setType("Datacenter");
@@ -427,22 +434,22 @@ public class DatacenterMO extends BaseMO {
         ObjectSpec oSpec = new ObjectSpec();
         oSpec.setObj(_mor);
         oSpec.setSkip(Boolean.TRUE);
-        oSpec.getSelectSet().add(datacenter2DvPortGroupTraversal);
+        oSpec.setSelectSet(new SelectionSpec[] { datacenter2DvPortGroupTraversal });
 
         PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-        pfSpec.getPropSet().add(pSpec);
-        pfSpec.getObjectSet().add(oSpec);
+        pfSpec.setPropSet(new PropertySpec[] { pSpec });
+        pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
         List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
         pfSpecArr.add(pfSpec);
 
-        List<ObjectContent> ocs = _context.getService().retrieveProperties(
-                _context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+        ObjectContent[] ocs = pc.retrieveProperties( pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
         if (ocs != null) {
             for (ObjectContent oc : ocs) {
-                List<DynamicProperty> props = oc.getPropSet();
+                DynamicProperty[] props = oc.getPropSet();
                 if (props != null) {
-                    assert (props.size() == 2);
+                    assert (props.length == 2);
                     for (DynamicProperty prop : props) {
                         if (prop.getName().equals("key")) {
                             dvPortGroupKey = (String) prop.getVal();
@@ -451,7 +458,7 @@ public class DatacenterMO extends BaseMO {
                             dvSwitchMor = (ManagedObjectReference) prop.getVal();
                         }
                     }
-                    if ((dvPortGroupKey != null) && dvPortGroupKey.equals(dvPortGroupMor.getValue())) {
+                    if ((dvPortGroupKey != null) && dvPortGroupKey.equals(dvPortGroupMor.getVal())) {
                         return dvSwitchMor;
                     }
                 }
@@ -474,7 +481,7 @@ public class DatacenterMO extends BaseMO {
         ManagedObjectReference dvsMor = getDvSwitchMor(networkInfo.first());
         String dvSwitchUuid = getDvSwitchUuid(dvsMor);
         dvPortConnection.setSwitchUuid(dvSwitchUuid);
-        dvPortConnection.setPortgroupKey(networkInfo.first().getValue());
+        dvPortConnection.setPortgroupKey(networkInfo.first().getVal());
         dvPortBacking.setPort(dvPortConnection);
         System.out.println("Plugging NIC device into network " + networkInfo.second() + " backed by dvSwitch: "
                 + dvSwitchUuid);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
index 4b2ce08..9581307 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DatastoreMO.java
@@ -31,6 +31,11 @@ import com.vmware.vim25.PropertyFilterSpec;
 import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.SelectionSpec;
 import com.vmware.vim25.TraversalSpec;
+import com.vmware.vim25.mo.Datacenter;
+import com.vmware.vim25.mo.Datastore;
+import com.vmware.vim25.mo.FileManager;
+import com.vmware.vim25.mo.PropertyCollector;
+import com.vmware.vim25.mo.Task;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.Pair;
@@ -40,13 +45,16 @@ public class DatastoreMO extends BaseMO {
 
 	private String _name;
 	private Pair<DatacenterMO, String> _ownerDc;
+	protected Datastore _datastore;
 
 	public DatastoreMO(VmwareContext context, ManagedObjectReference morDatastore) {
 		super(context, morDatastore);
+		_datastore = (Datastore) this.getManagedEntity();
 	}
 
 	public DatastoreMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_datastore = (Datastore) this.getManagedEntity();
 	}
 
 	@Override
@@ -77,7 +85,7 @@ public class DatastoreMO extends BaseMO {
 
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("Datacenter");
-		pSpec.getPathSet().add("name");
+		pSpec.setPathSet(new String[] { "name" });
 
 	    TraversalSpec folderParentTraversal = new TraversalSpec();
 	    folderParentTraversal.setType("Folder");
@@ -85,45 +93,46 @@ public class DatastoreMO extends BaseMO {
 	    folderParentTraversal.setName("folderParentTraversal");
 	    SelectionSpec sSpec = new SelectionSpec();
 	    sSpec.setName("folderParentTraversal");
-	    folderParentTraversal.getSelectSet().add(sSpec);
+	    folderParentTraversal.setSelectSet( new SelectionSpec[] { sSpec });
 
 	    TraversalSpec dsParentTraversal = new TraversalSpec();
 	    dsParentTraversal.setType("Datastore");
 	    dsParentTraversal.setPath("parent");
 	    dsParentTraversal.setName("dsParentTraversal");
-	    dsParentTraversal.getSelectSet().add(folderParentTraversal);
+	    dsParentTraversal.setSelectSet(new TraversalSpec[] { folderParentTraversal });
 
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(getMor());
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(dsParentTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { dsParentTraversal });
 
 	    PropertyFilterSpec pfSpec = new PropertyFilterSpec();
-	    pfSpec.getPropSet().add(pSpec);
-	    pfSpec.getObjectSet().add(oSpec);
+	    pfSpec.setPropSet(new PropertySpec[] { pSpec });
+	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
         List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
         pfSpecArr.add(pfSpec);
 
-	    List<ObjectContent> ocs = _context.getService().retrieveProperties(
-	    	_context.getPropertyCollector(), pfSpecArr);
+        PropertyCollector pc = _context.getPropertyCollector();
+	    ObjectContent[] ocs = pc.retrieveProperties(pfSpecArr.toArray(new PropertyFilterSpec[0]));
 
-	    assert(ocs != null && ocs.size() > 0);
-	    assert(ocs.get(0).getObj() != null);
-	    assert(ocs.get(0).getPropSet() != null);
-	    String dcName = ocs.get(0).getPropSet().get(0).getVal().toString();
-	    _ownerDc = new Pair<DatacenterMO, String>(new DatacenterMO(_context, ocs.get(0).getObj()), dcName);
+	    assert(ocs != null && ocs.length > 0);
+	    assert(ocs[0].getObj() != null);
+	    assert(ocs[0].getPropSet() != null);
+	    String dcName = ocs[0].getPropSet()[0].getVal().toString();
+	    _ownerDc = new Pair<DatacenterMO, String>(new DatacenterMO(_context, ocs[0].getObj()), dcName);
 	    return _ownerDc;
 	}
 
 	public void makeDirectory(String path, ManagedObjectReference morDc) throws Exception {
 		String datastoreName = getName();
-		ManagedObjectReference morFileManager = _context.getServiceContent().getFileManager();
+		Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+		FileManager fileManager = _context.getFileManager();
 
 		String fullPath = path;
 		if(!DatastoreFile.isFullDatastorePath(fullPath))
 			fullPath = String.format("[%s] %s", datastoreName, path);
 
-		_context.getService().makeDirectory(morFileManager, fullPath, morDc, true);
+		fileManager.makeDirectory(fullPath, datacenter, true);
 	}
 	
 	public String getDatastoreRootPath() throws Exception {
@@ -169,8 +178,9 @@ public class DatastoreMO extends BaseMO {
 			s_logger.info("Unable to test file existence due to exception " + e.getClass().getName() + ", skip deleting of it");
 			return true;
 		}
-
-		ManagedObjectReference morTask = _context.getService().deleteDatastoreFileTask(morFileManager, fullPath, morDc);
+		Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+		Task task = _context.getFileManager().deleteDatastoreFile_Task(fullPath, datacenter);
+		ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(result) {
@@ -190,17 +200,18 @@ public class DatastoreMO extends BaseMO {
 		DatastoreMO destDsMo = new DatastoreMO(_context, morDestDs);
 		String destDsName = destDsMo.getName();
 
-		ManagedObjectReference morFileManager = _context.getServiceContent().getFileManager();
+		Datacenter sourceDatacenter = new Datacenter(_context.getServerConnection(), morSrcDc);
 		String srcFullPath = srcFilePath;
 		if(!DatastoreFile.isFullDatastorePath(srcFullPath))
 			srcFullPath = String.format("[%s] %s", srcDsName, srcFilePath);
 
+		Datacenter destinationDatacenter = new Datacenter(_context.getServerConnection(), morDestDc);
 		String destFullPath = destFilePath;
 		if(!DatastoreFile.isFullDatastorePath(destFullPath))
 			destFullPath = String.format("[%s] %s", destDsName, destFilePath);
 
-		ManagedObjectReference morTask = _context.getService().copyDatastoreFileTask(morFileManager,
-			srcFullPath, morSrcDc, destFullPath, morDestDc, forceOverwrite);
+		Task task = _context.getFileManager().copyDatastoreFile_Task(srcFullPath, sourceDatacenter, destFullPath, destinationDatacenter, forceOverwrite);
+		ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(result) {
@@ -220,17 +231,18 @@ public class DatastoreMO extends BaseMO {
 		DatastoreMO destDsMo = new DatastoreMO(_context, morDestDs);
 		String destDsName = destDsMo.getName();
 
-		ManagedObjectReference morFileManager = _context.getServiceContent().getFileManager();
+        Datacenter sourceDatacenter = new Datacenter(_context.getServerConnection(), morSrcDc);
 		String srcFullPath = srcFilePath;
 		if(!DatastoreFile.isFullDatastorePath(srcFullPath))
 			srcFullPath = String.format("[%s] %s", srcDsName, srcFilePath);
 
+        Datacenter destinationDatacenter = new Datacenter(_context.getServerConnection(), morDestDc);
 		String destFullPath = destFilePath;
 		if(!DatastoreFile.isFullDatastorePath(destFullPath))
 			destFullPath = String.format("[%s] %s", destDsName, destFilePath);
 
-		ManagedObjectReference morTask = _context.getService().moveDatastoreFileTask(morFileManager,
-			srcFullPath, morSrcDc, destFullPath, morDestDc, forceOverwrite);
+		Task task = _context.getFileManager().moveDatastoreFile_Task(srcFullPath, sourceDatacenter, destFullPath, destinationDatacenter, forceOverwrite);
+		ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(result) {
@@ -307,8 +319,8 @@ public class DatastoreMO extends BaseMO {
 		s_logger.info("Search file " + file.getFileName() + " on " + dirFile.getPath());
 		HostDatastoreBrowserSearchResults results = browserMo.searchDatastore(dirFile.getPath(), file.getFileName(), true);
 		if(results != null) {
-			List<FileInfo> info = results.getFile();
-			if(info != null && info.size() > 0) {
+			FileInfo[] info = results.getFile();
+			if(info != null && info.length > 0) {
 				s_logger.info("File " + fileFullPath + " exists on datastore");
 				return true;
 			}
@@ -323,8 +335,8 @@ public class DatastoreMO extends BaseMO {
 
 		HostDatastoreBrowserSearchResults results = browserMo.searchDatastore(folderParentDatastorePath, folderName, true);
 		if(results != null) {
-			List<FileInfo> info = results.getFile();
-			if(info != null && info.size() > 0) {
+			FileInfo[] info = results.getFile();
+			if(info != null && info.length > 0) {
 				s_logger.info("Folder " + folderName + " exists on datastore");
 				return true;
 			}
@@ -351,8 +363,8 @@ public class DatastoreMO extends BaseMO {
             s_logger.warn("Multiple files with name " + fileName + " exists in datastore " + datastorePath + ". Trying to choose first file found in search attempt.");
         }
         for (HostDatastoreBrowserSearchResults result : results) {
-            List<FileInfo> info = result.getFile();
-            if (info != null && info.size() > 0) {
+            FileInfo[] info = result.getFile();
+            if (info != null && info.length > 0) {
                 for (FileInfo fi : info) {
                     absoluteFileName = parentFolderPath = result.getFolderPath();
                     s_logger.info("Found file " + fileName + " in datastore at " + absoluteFileName);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java
index fde4bea..bcc812b 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java
@@ -24,6 +24,7 @@ import java.util.Map;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.DVPortgroupConfigSpec;
 import com.vmware.vim25.DVSConfigInfo;
 import com.vmware.vim25.ManagedObjectReference;
@@ -31,37 +32,49 @@ import com.vmware.vim25.TaskInfo;
 import com.vmware.vim25.VMwareDVSConfigInfo;
 import com.vmware.vim25.VMwareDVSConfigSpec;
 import com.vmware.vim25.VMwareDVSPvlanMapEntry;
+import com.vmware.vim25.mo.DistributedVirtualPortgroup;
+import com.vmware.vim25.mo.DistributedVirtualSwitch;
+import com.vmware.vim25.mo.Task;
 
 public class DistributedVirtualSwitchMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class);
 
+    protected DistributedVirtualSwitch _distributedVirtualSwitch;
+    
     public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) {
         super(context, morDvs);
+        _distributedVirtualSwitch = (DistributedVirtualSwitch) this.getManagedEntity();
     }
 
     public DistributedVirtualSwitchMO(VmwareContext context, String morType, String morValue) {
         super(context, morType, morValue);
+        _distributedVirtualSwitch = (DistributedVirtualSwitch) this.getManagedEntity();
     }
 
     public void createDVPortGroup(DVPortgroupConfigSpec dvPortGroupSpec) throws Exception {
         List<DVPortgroupConfigSpec> dvPortGroupSpecArray = new ArrayList<DVPortgroupConfigSpec>();
         dvPortGroupSpecArray.add(dvPortGroupSpec);
-        _context.getService().addDVPortgroup_Task(_mor, dvPortGroupSpecArray.toArray(new DVPortgroupConfigSpec[0]));
+        _distributedVirtualSwitch.addDVPortgroup_Task(dvPortGroupSpecArray.toArray(new DVPortgroupConfigSpec[0]));
     }
 
     public void updateDvPortGroup(ManagedObjectReference dvPortGroupMor, DVPortgroupConfigSpec dvPortGroupSpec) throws Exception {
         // TODO(sateesh): Update numPorts
-        _context.getService().reconfigureDVPortgroup_Task(dvPortGroupMor, dvPortGroupSpec);
+        DistributedVirtualPortgroup dvPortGroup = new DistributedVirtualPortgroup(_context.getServerConnection(), dvPortGroupMor);
+        dvPortGroup.reconfigureDVPortgroup_Task(dvPortGroupSpec);
     }
 
     public void updateVMWareDVSwitch(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
-        _context.getService().reconfigureDvs_Task(dvSwitchMor, dvsSpec);
+        // FIXME Why pass in a dvSwitchMor here?
+        DistributedVirtualSwitch dvSwitch = new DistributedVirtualSwitch(_context.getServerConnection(), dvSwitchMor);
+        dvSwitch.reconfigureDvs_Task(dvsSpec);
     }
 
     public TaskInfo updateVMWareDVSwitchGetTask(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
-        ManagedObjectReference task = _context.getService().reconfigureDvs_Task(dvSwitchMor, dvsSpec);
-        TaskInfo info = (TaskInfo) (_context.getVimClient().getDynamicProperty(task, "info"));
-        boolean waitvalue = _context.getVimClient().waitForTask(task);
+        // FIXME Why pass in a dvSwitchMor here?
+        DistributedVirtualSwitch dvSwitch = new DistributedVirtualSwitch(_context.getServerConnection(), dvSwitchMor);
+        Task task = dvSwitch.reconfigureDvs_Task(dvsSpec);
+        TaskInfo info = (TaskInfo) (_context.getVimClient().getDynamicProperty(task.getMOR(), "info"));
+        _context.getVimClient().waitForTask(task.getMOR());
         return info;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreBrowserMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreBrowserMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreBrowserMO.java
index 8ef4b40..9bd7dae 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreBrowserMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreBrowserMO.java
@@ -21,27 +21,34 @@ import java.util.ArrayList;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.HostDatastoreBrowserSearchResults;
 import com.vmware.vim25.HostDatastoreBrowserSearchSpec;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.HostDatastoreBrowser;
+import com.vmware.vim25.mo.Task;
 
 public class HostDatastoreBrowserMO extends BaseMO {
 
     private static final Logger s_logger = Logger.getLogger(HostDatastoreBrowserMO.class);
+    
+    protected HostDatastoreBrowser _hostDatastoreBrowser;
 
 	public HostDatastoreBrowserMO(VmwareContext context, ManagedObjectReference morHostDatastoreBrowser) {
 		super(context, morHostDatastoreBrowser);
+		_hostDatastoreBrowser = new HostDatastoreBrowser(context.getServerConnection(), morHostDatastoreBrowser);
 	}
 
 	public HostDatastoreBrowserMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostDatastoreBrowser = new HostDatastoreBrowser(context.getServerConnection(), this._mor);
 	}
 
 	public void DeleteFile(String datastoreFullPath) throws Exception {
 		if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - deleteFile(). target mor: " + _mor.getVal() + ", file datastore path: " + datastoreFullPath);
 
-		_context.getService().deleteFile(_mor, datastoreFullPath);
+		_hostDatastoreBrowser.deleteFile(datastoreFullPath);
 
 		if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - deleteFile() done");
@@ -52,7 +59,8 @@ public class HostDatastoreBrowserMO extends BaseMO {
 			s_logger.trace("vCenter API trace - searchDatastore(). target mor: " + _mor.getVal() + ", file datastore path: " + datastorePath);
 
 		try {
-			ManagedObjectReference morTask = _context.getService().searchDatastore_Task(_mor, datastorePath, searchSpec);
+		    Task task = _hostDatastoreBrowser.searchDatastore_Task(datastorePath, searchSpec);
+			ManagedObjectReference morTask = task.getMOR();
 
 			boolean result = _context.getVimClient().waitForTask(morTask);
 			if(result) {
@@ -84,7 +92,8 @@ public class HostDatastoreBrowserMO extends BaseMO {
 			s_logger.trace("vCenter API trace - searchDatastoreSubFolders(). target mor: " + _mor.getVal() + ", file datastore path: " + datastorePath);
 
 		try {
-			ManagedObjectReference morTask = _context.getService().searchDatastoreSubFolders_Task(_mor, datastorePath, searchSpec);
+		    Task task = _hostDatastoreBrowser.searchDatastoreSubFolders_Task(datastorePath, searchSpec);
+			ManagedObjectReference morTask = task.getMOR();
 
 			boolean result = _context.getVimClient().waitForTask(morTask);
 			if(result) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
index ca482b3..cdebbdb 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
@@ -22,6 +22,7 @@ import java.util.Arrays;
 import java.util.List;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.CustomFieldStringValue;
 import com.vmware.vim25.DatastoreInfo;
 import com.vmware.vim25.DynamicProperty;
@@ -36,15 +37,22 @@ import com.vmware.vim25.PropertySpec;
 import com.vmware.vim25.TraversalSpec;
 import com.vmware.vim25.VmfsDatastoreCreateSpec;
 import com.vmware.vim25.VmfsDatastoreOption;
+import com.vmware.vim25.mo.Datastore;
+import com.vmware.vim25.mo.HostDatastoreSystem;
+import com.vmware.vim25.mo.PropertyCollector;
 
 public class HostDatastoreSystemMO extends BaseMO {
 
+    protected HostDatastoreSystem _hostDatastoreSystem;
+    
 	public HostDatastoreSystemMO(VmwareContext context, ManagedObjectReference morHostDatastore) {
 		super(context, morHostDatastore);
+		_hostDatastoreSystem = new HostDatastoreSystem(context.getServerConnection(), morHostDatastore);
 	}
 
 	public HostDatastoreSystemMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostDatastoreSystem = new HostDatastoreSystem(context.getServerConnection(), this._mor);
 	}
 
 	public ManagedObjectReference findDatastore(String name) throws Exception {
@@ -144,31 +152,32 @@ public class HostDatastoreSystemMO extends BaseMO {
 	}
 
 	public HostScsiDisk[] queryAvailableDisksForVmfs() throws Exception {
-		return _context.getService().queryAvailableDisksForVmfs(_mor, null);
+		return _hostDatastoreSystem.queryAvailableDisksForVmfs(null);
 	}
 
-	public ManagedObjectReference createVmfsDatastore(String datastoreName, HostScsiDisk hostScsiDisk) throws Exception {
+	public Datastore createVmfsDatastore(String datastoreName, HostScsiDisk hostScsiDisk) throws Exception {
 		// just grab the first instance of VmfsDatastoreOption
-		VmfsDatastoreOption vmfsDatastoreOption = _context.getService().queryVmfsDatastoreCreateOptions(_mor, hostScsiDisk.getDevicePath(), 5)[0];
+		VmfsDatastoreOption vmfsDatastoreOption = _hostDatastoreSystem.queryVmfsDatastoreCreateOptions(hostScsiDisk.getDevicePath(), 5)[0];
 
 		VmfsDatastoreCreateSpec vmfsDatastoreCreateSpec = (VmfsDatastoreCreateSpec)vmfsDatastoreOption.getSpec();
 
 		// set the name of the datastore to be created
 		vmfsDatastoreCreateSpec.getVmfs().setVolumeName(datastoreName);
 
-		return _context.getService().createVmfsDatastore(_mor, vmfsDatastoreCreateSpec);
+		return _hostDatastoreSystem.createVmfsDatastore(vmfsDatastoreCreateSpec);
 	}
 
 	public boolean deleteDatastore(String name) throws Exception {
 		ManagedObjectReference morDatastore = findDatastore(name);
+		Datastore datastore = new Datastore(_context.getServerConnection(), morDatastore);
 		if(morDatastore != null) {
-			_context.getService().removeDatastore(_mor, morDatastore);
+			_hostDatastoreSystem.removeDatastore(datastore);
 			return true;
 		}
 		return false;
 	}
 
-	public ManagedObjectReference createNfsDatastore(String host, int port,
+	public Datastore createNfsDatastore(String host, int port,
 		String exportPath, String uuid) throws Exception {
 
 		HostNasVolumeSpec spec = new HostNasVolumeSpec();
@@ -179,7 +188,7 @@ public class HostDatastoreSystemMO extends BaseMO {
 
 		// readOnly/readWrite
 		spec.setAccessMode("readWrite");
-		return _context.getService().createNasDatastore(_mor, spec);
+		return _hostDatastoreSystem.createNasDatastore(spec);
 	}
 
 	public List<ManagedObjectReference> getDatastores() throws Exception {
@@ -219,8 +228,8 @@ public class HostDatastoreSystemMO extends BaseMO {
 	    pfSpec.setObjectSet(new ObjectSpec[] { oSpec });
         List<PropertyFilterSpec> pfSpecArr = new ArrayList<PropertyFilterSpec>();
         pfSpecArr.add(pfSpec);
-
-	    return _context.getService().retrieveProperties(
-	    	_context.getPropertyCollector(), pfSpecArr.toArray(new PropertyFilterSpec[0]));
+        
+        PropertyCollector pc = _context.getPropertyCollector();
+	    return pc.retrieveProperties(pfSpecArr.toArray(new PropertyFilterSpec[0]));
 	}
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java
index df15926..1d52ada 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java
@@ -19,19 +19,25 @@ package com.cloud.hypervisor.vmware.mo;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.HostFirewallDefaultPolicy;
 import com.vmware.vim25.HostFirewallInfo;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.HostFirewallSystem;
 
 public class HostFirewallSystemMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(HostFirewallSystemMO.class);
+    
+    protected HostFirewallSystem _hostFirewallSystem;
 
 	public HostFirewallSystemMO(VmwareContext context, ManagedObjectReference morFirewallSystem) {
 		super(context, morFirewallSystem);
+		_hostFirewallSystem = new HostFirewallSystem(context.getServerConnection(), morFirewallSystem);
 	}
 
 	public HostFirewallSystemMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostFirewallSystem = new HostFirewallSystem(context.getServerConnection(), this._mor);
 	}
 
 	public HostFirewallInfo getFirewallInfo() throws Exception {
@@ -39,18 +45,18 @@ public class HostFirewallSystemMO extends BaseMO {
 	}
 
 	public void updateDefaultPolicy(HostFirewallDefaultPolicy policy) throws Exception {
-		_context.getService().updateDefaultPolicy(_mor, policy);
+		_hostFirewallSystem.updateDefaultPolicy(policy);
 	}
 
 	public void enableRuleset(String rulesetName) throws Exception {
-		_context.getService().enableRuleset(_mor, rulesetName);
+		_hostFirewallSystem.enableRuleset(rulesetName);
 	}
 
 	public void disableRuleset(String rulesetName) throws Exception {
-		_context.getService().disableRuleset(_mor, rulesetName);
+		_hostFirewallSystem.disableRuleset(rulesetName);
 	}
 
 	public void refreshFirewall() throws Exception {
-		_context.getService().refreshFirewall(_mor);
+		_hostFirewallSystem.refreshFirewall();
 	}
 }


Mime
View raw message