cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h...@apache.org
Subject [3/4] Move away from the services model and fix all resulting errors
Date Tue, 24 Sep 2013 03:54:44 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
index 07b8be4..05da248 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
@@ -30,9 +30,10 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.hypervisor.vmware.util.VmwareHelper;
 import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
+
 import com.google.gson.Gson;
 import com.vmware.vim25.AboutInfo;
-import com.vmware.vim25.AlreadyExistsFaultMsg;
+import com.vmware.vim25.AlreadyExists;
 import com.vmware.vim25.ClusterDasConfigInfo;
 import com.vmware.vim25.ComputeResourceSummary;
 import com.vmware.vim25.CustomFieldStringValue;
@@ -67,24 +68,34 @@ import com.vmware.vim25.VirtualMachineConfigSpec;
 import com.vmware.vim25.VirtualMachinePowerState;
 import com.vmware.vim25.VirtualNicManagerNetConfig;
 import com.vmware.vim25.NasDatastoreInfo;
+import com.vmware.vim25.mo.Datastore;
+import com.vmware.vim25.mo.Folder;
+import com.vmware.vim25.mo.HostSystem;
+import com.vmware.vim25.mo.PropertyCollector;
+import com.vmware.vim25.mo.ResourcePool;
+import com.vmware.vim25.mo.Task;
+import com.vmware.vim25.mo.VirtualMachineSnapshot;
 
 import java.util.Arrays;
 
 public class HostMO extends BaseMO implements VmwareHypervisorHost {
     private static final Logger s_logger = Logger.getLogger(HostMO.class);
     Map<String, VirtualMachineMO> _vmCache = new HashMap<String, VirtualMachineMO>();
-    //Map<String, String> _vmInternalNameMapCache = new HashMap<String, String>();
+
+    protected HostSystem _hostSystem;
 
 	public HostMO (VmwareContext context, ManagedObjectReference morHost) {
 		super(context, morHost);
+		_hostSystem = new HostSystem(context.getServerConnection(), morHost);
 	}
 
 	public HostMO (VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostSystem  = new HostSystem(context.getServerConnection(), this._mor);
 	}
 
 	public HostHardwareSummary getHostHardwareSummary() throws Exception {
-		HostConnectInfo hostInfo = _context.getService().queryHostConnectionInfo(_mor);
+		HostConnectInfo hostInfo = _hostSystem.queryHostConnectionInfo();
 		HostHardwareSummary hardwareSummary = hostInfo.getHost().getHardware();
 		return hardwareSummary;
 	}
@@ -119,7 +130,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 		HostNetworkInfo hostNetInfo = getHostNetworkInfo();
 
-		List<HostPortGroup> portGroups = hostNetInfo.getPortgroup();
+		HostPortGroup[] portGroups = hostNetInfo.getPortgroup();
 		if(portGroups != null) {
 			for(HostPortGroup portGroup : portGroups) {
 				HostPortGroupSpec spec = portGroup.getSpec();
@@ -183,7 +194,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] { "name"} );
 		if(ocs != null && ocs.length > 0) {
     		for(ObjectContent oc : ocs) {
-		        List<DynamicProperty> objProps = oc.getPropSet();
+		        DynamicProperty[] objProps = oc.getPropSet();
 		        if(objProps != null) {
 		        	for(DynamicProperty objProp : objProps) {
 		        		if(objProp.getVal().toString().equals(datastoreName))
@@ -242,7 +253,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		if(datastores != null) {
 			for(ManagedObjectReference mor : datastores) {
 				DatastoreSummary summary = (DatastoreSummary)_context.getVimClient().getDynamicProperty(mor, "summary");
-				if(summary.getType().equalsIgnoreCase("VMFS") && !summary.isMultipleHostAccess())
+				if(summary.getType().equalsIgnoreCase("VMFS") && !summary.getMultipleHostAccess())
 					l.add(mor);
 			}
 		}
@@ -312,7 +323,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 	public String getPortGroupVirtualSwitchName(String portGroupName) throws Exception {
 		HostNetworkInfo hostNetInfo = getHostNetworkInfo();
-		List<HostPortGroup> portGroups = hostNetInfo.getPortgroup();
+		HostPortGroup[] portGroups = hostNetInfo.getPortgroup();
 		if(portGroups != null) {
 			for(HostPortGroup portGroup : portGroups) {
 				HostPortGroupSpec spec = portGroup.getSpec();
@@ -326,7 +337,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 	public HostPortGroupSpec getPortGroupSpec(String portGroupName) throws Exception {
 		HostNetworkInfo hostNetInfo = getHostNetworkInfo();
-		List<HostPortGroup> portGroups = hostNetInfo.getPortgroup();
+		HostPortGroup[] portGroups = hostNetInfo.getPortgroup();
 		if(portGroups != null) {
 			for(HostPortGroup portGroup : portGroups) {
 				HostPortGroupSpec spec = portGroup.getSpec();
@@ -347,7 +358,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		if(netConfigs != null) {
 			for(VirtualNicManagerNetConfig netConfig : netConfigs) {
 				if(netConfig.getNicType().equals(nicType.toString())) {
-					List<HostVirtualNic> nics = netConfig.getCandidateVnic();
+					HostVirtualNic[] nics = netConfig.getCandidateVnic();
 					if(nics != null) {
 						for(HostVirtualNic nic : nics) {
 							return nic.getPortgroup();
@@ -361,7 +372,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 			// ESX management network is configured in service console
 			HostNetworkInfo netInfo = getHostNetworkInfo();
 			assert(netInfo != null);
-			List<HostVirtualNic> nics = netInfo.getConsoleVnic();
+			HostVirtualNic[] nics = netInfo.getConsoleVnic();
 			if(nics != null) {
 				for(HostVirtualNic nic : nics) {
 					return nic.getPortgroup();
@@ -427,7 +438,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	public ManagedObjectReference getNetworkMor(String portGroupName) throws Exception {
 		PropertySpec pSpec = new PropertySpec();
 		pSpec.setType("Network");
-		pSpec.getPathSet().add("summary.name");
+		pSpec.setPathSet(new String[] { "summary.name" });
 
 	    TraversalSpec host2NetworkTraversal = new TraversalSpec();
 	    host2NetworkTraversal.setType("HostSystem");
@@ -437,20 +448,20 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(host2NetworkTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { host2NetworkTraversal });
 
 	    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(portGroupName))
@@ -520,7 +531,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
         ObjectContent[] ocs = getVmPropertiesOnHyperHost(new String[] { "name", "value[" + key + "]" });
         if(ocs != null && ocs.length > 0) {
             for(ObjectContent oc : ocs) {
-                List<DynamicProperty> props = oc.getPropSet();
+                DynamicProperty[] props = oc.getPropSet();
                 if (props != null) {
                     String vmVcenterName = null;
                     String vmInternalCSName = null;
@@ -568,9 +579,13 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		assert(vmSpec != null);
 		DatacenterMO dcMo = new DatacenterMO(_context, getHyperHostDatacenter());
         ManagedObjectReference morPool = getHyperHostOwnerResourcePool();
-
-	    ManagedObjectReference morTask = _context.getService().createVMTask(
-	    	dcMo.getVmFolder(), vmSpec, morPool, _mor);
+        
+        Folder vmFolder = dcMo._datacenter.getVmFolder();
+        ResourcePool pool = new ResourcePool(_context.getServerConnection(), morPool);
+        
+        Task task = vmFolder.createVM_Task(vmSpec, pool, _hostSystem);
+	    ManagedObjectReference morTask = task.getMOR();
+	    
 		boolean result = _context.getVimClient().waitForTask(morTask);
 
 		if(result) {
@@ -596,7 +611,7 @@ public class HostMO 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 vmName = null;
 		        	String value = null;
@@ -629,11 +644,11 @@ public class HostMO 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 host2VmTraversal = new TraversalSpec();
 	    host2VmTraversal.setType("HostSystem");
@@ -643,30 +658,30 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(host2VmTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { host2VmTraversal });
 
 	    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 host2DatastoreTraversal = new TraversalSpec();
 	    host2DatastoreTraversal.setType("HostSystem");
@@ -676,31 +691,31 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	    ObjectSpec oSpec = new ObjectSpec();
 	    oSpec.setObj(_mor);
 	    oSpec.setSkip(Boolean.TRUE);
-	    oSpec.getSelectSet().add(host2DatastoreTraversal);
+	    oSpec.setSelectSet(new TraversalSpec[] { host2DatastoreTraversal });
 
 	    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;
 	}
 
 	public List<Pair<ManagedObjectReference, String>> getDatastoreMountsOnHost() throws Exception {
 		List<Pair<ManagedObjectReference, String>> mounts = new ArrayList<Pair<ManagedObjectReference, String>>();
 
 		ObjectContent[] ocs = getDatastorePropertiesOnHyperHost(new String[] {
-			String.format("host[\"%s\"].mountInfo.path", _mor.getValue()) });
+			String.format("host[\"%s\"].mountInfo.path", _mor.getVal()) });
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
 				Pair<ManagedObjectReference, String> mount = new Pair<ManagedObjectReference, String>(
-					oc.getObj(), oc.getPropSet().get(0).getVal().toString());
+					oc.getObj(), oc.getPropSet()[0].getVal().toString());
 				mounts.add(mount);
 			}
 		}
@@ -714,7 +729,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		if(ocs != null) {
 			for(ObjectContent oc : ocs) {
 				DatastoreSummary dsSummary = (DatastoreSummary)VmwareHelper.getPropValue(oc, "summary");
-				if(dsSummary.isMultipleHostAccess() == false && dsSummary.isAccessible() && dsSummary.getType().equalsIgnoreCase("vmfs")) {
+				if(dsSummary.getMultipleHostAccess() == false && dsSummary.isAccessible() && dsSummary.getType().equalsIgnoreCase("vmfs")) {
 					ManagedObjectReference morDs = oc.getObj();
 					String name = (String)VmwareHelper.getPropValue(oc, "name");
 
@@ -727,7 +742,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 	public void importVmFromOVF(String ovfFilePath, String vmName, String datastoreName, String diskOption) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName
+			s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getVal() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName
 				+ ",datastoreName: " + datastoreName + ", diskOption: " + diskOption);
 
 		DatastoreMO dsMo = getHostDatastoreMO(datastoreName);
@@ -754,9 +769,9 @@ public class HostMO 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);
@@ -804,7 +819,7 @@ public class HostMO 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);
 
     	HostDatastoreSystemMO hostDatastoreSystemMo = getHostDatastoreSystemMO();
@@ -812,14 +827,15 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
         if(morDatastore == null) {
         	if(!vmfsDatastore) {
                 try {
-                    morDatastore = hostDatastoreSystemMo.createNfsDatastore(
+                    Datastore datastore = hostDatastoreSystemMo.createNfsDatastore(
                             poolHostAddress,
                             poolHostPort,
                             poolPath,
                             poolUuid);
-                } catch (AlreadyExistsFaultMsg e) {
+                    morDatastore = datastore.getMOR();
+                } catch (AlreadyExists e) {
                     s_logger.info("Creation of NFS datastore on vCenter failed since datastore already exists." +
-                            " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " +
+                            " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getVal() + ", vmfs: " +
                             vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort +
                             ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
                     // Retrieve the morDatastore and return it.
@@ -827,7 +843,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
                             poolHostPort, poolPath, poolUuid, hostDatastoreSystemMo));
                 } catch (Exception e) {
                     s_logger.info("Creation of NFS datastore on vCenter failed. " +
-                            " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " +
+                            " Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getVal() + ", vmfs: " +
                             vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort +
                             ", poolPath: " + poolPath + ", poolUuid: " + poolUuid + ". Exception mesg: " + e.getMessage());
                     throw new Exception("Creation of NFS datastore on vCenter failed.");
@@ -868,7 +884,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	public void unmountDatastore(String uuid) throws Exception {
 
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", uuid: " + uuid);
+			s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getVal() + ", uuid: " + uuid);
 
     	HostDatastoreSystemMO hostDatastoreSystemMo = getHostDatastoreSystemMO();
     	if(!hostDatastoreSystemMo.deleteDatastore(uuid)) {
@@ -904,7 +920,7 @@ public class HostMO 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();
 
@@ -922,7 +938,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public VmwareHypervisorHostNetworkSummary getHyperHostNetworkSummary(String managementPortGroup) throws Exception {
 	    if(s_logger.isTraceEnabled())
-			s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + managementPortGroup);
+			s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getVal() + ", mgmtPortgroup: " + managementPortGroup);
 
 		VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
 
@@ -974,7 +990,7 @@ public class HostMO 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());
 
 		//
 		// This is to adopt the model when using Cluster as a big host while ComputeResourceSummary is used
@@ -1015,13 +1031,14 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	@Override
 	public boolean isHyperHostConnected() throws Exception {
     	HostRuntimeInfo runtimeInfo = (HostRuntimeInfo)_context.getVimClient().getDynamicProperty(_mor, "runtime");
-    	return runtimeInfo.getConnectionState() == HostSystemConnectionState.CONNECTED;
+    	return runtimeInfo.getConnectionState() == HostSystemConnectionState.connected;
 	}
 
     public boolean revertToSnapshot(ManagedObjectReference morSnapshot)
             throws Exception {
-        ManagedObjectReference morTask = _context.getService()
-                .revertToSnapshotTask(morSnapshot, _mor, false);
+        VirtualMachineSnapshot snapshot = new VirtualMachineSnapshot(_context.getServerConnection(), morSnapshot);
+        Task task = snapshot.revertToSnapshot_Task(_hostSystem, false);
+        ManagedObjectReference morTask = task.getMOR();
         boolean result = _context.getVimClient().waitForTask(morTask);
         if (result) {
             _context.waitForTaskProgressDone(morTask);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java
index 989b839..722adae 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java
@@ -19,47 +19,52 @@ package com.cloud.hypervisor.vmware.mo;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.HostPortGroupSpec;
 import com.vmware.vim25.HostVirtualSwitchSpec;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.HostNetworkSystem;
 
 public class HostNetworkSystemMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(HostNetworkSystemMO.class);
+    protected HostNetworkSystem _hostNetworkSystem;
     
 	public HostNetworkSystemMO(VmwareContext context, ManagedObjectReference morNetworkSystem) {
 		super(context, morNetworkSystem);
+		_hostNetworkSystem = new HostNetworkSystem(context.getServerConnection(), morNetworkSystem);
 	}
 	
 	public HostNetworkSystemMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostNetworkSystem = new HostNetworkSystem(context.getServerConnection(), _mor);
 	}
 	
 	public void addPortGroup(HostPortGroupSpec spec) throws Exception {
-		_context.getService().addPortGroup(_mor, spec);
+		_hostNetworkSystem.addPortGroup(spec);
 	}
 	
 	public void updatePortGroup(String portGroupName, HostPortGroupSpec spec) throws Exception {
-		_context.getService().updatePortGroup(_mor, portGroupName, spec);
+		_hostNetworkSystem.updatePortGroup(portGroupName, spec);
 	}
 	
 	public void removePortGroup(String portGroupName) throws Exception {
-		_context.getService().removePortGroup(_mor, portGroupName);
+		_hostNetworkSystem.removePortGroup(portGroupName);
 	}
 	
 	public void addVirtualSwitch(String vSwitchName, HostVirtualSwitchSpec spec) throws Exception {
-		_context.getService().addVirtualSwitch(_mor, vSwitchName, spec);
+		_hostNetworkSystem.addVirtualSwitch(vSwitchName, spec);
 	}
 	
 	public void updateVirtualSwitch(String vSwitchName, HostVirtualSwitchSpec spec) throws Exception {
-		_context.getService().updateVirtualSwitch(_mor, vSwitchName, spec);
+		_hostNetworkSystem.updateVirtualSwitch(vSwitchName, spec);
 	}
 	
 	public void removeVirtualSwitch(String vSwitchName) throws Exception {
-		_context.getService().removeVirtualSwitch(_mor, vSwitchName);
+		_hostNetworkSystem.removeVirtualSwitch(vSwitchName);
 	}
 	
 	public void refresh() throws Exception {
-		_context.getService().refreshNetworkSystem(_mor);
+		_hostNetworkSystem.refreshNetworkSystem();
 	}
 }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostStorageSystemMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostStorageSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostStorageSystemMO.java
index 0270091..bdc8e98 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostStorageSystemMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostStorageSystemMO.java
@@ -23,14 +23,19 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.vmware.vim25.HostInternetScsiHbaStaticTarget;
 import com.vmware.vim25.HostStorageDeviceInfo;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.HostStorageSystem;
 
 public class HostStorageSystemMO extends BaseMO {
+    protected HostStorageSystem _hostStorageSystem;
+    
 	public HostStorageSystemMO(VmwareContext context, ManagedObjectReference morHostDatastore) {
 		super(context, morHostDatastore);
+		_hostStorageSystem = new HostStorageSystem(context.getServerConnection(), morHostDatastore);
 	}
 
 	public HostStorageSystemMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_hostStorageSystem = new HostStorageSystem(context.getServerConnection(), _mor);
 	}
 	
 	public HostStorageDeviceInfo getStorageDeviceInfo() throws Exception {
@@ -38,18 +43,18 @@ public class HostStorageSystemMO extends BaseMO {
 	}
 	
 	public void addInternetScsiStaticTargets(String iScsiHbaDevice, List<HostInternetScsiHbaStaticTarget> lstTargets) throws Exception {
-		_context.getService().addInternetScsiStaticTargets(_mor, iScsiHbaDevice, lstTargets.toArray(new HostInternetScsiHbaStaticTarget[0]));
+		_hostStorageSystem.addInternetScsiStaticTargets(iScsiHbaDevice, lstTargets.toArray(new HostInternetScsiHbaStaticTarget[0]));
 	}
 	
 	public void removeInternetScsiStaticTargets(String iScsiHbaDevice, List<HostInternetScsiHbaStaticTarget> lstTargets) throws Exception {
-		_context.getService().removeInternetScsiStaticTargets(_mor, iScsiHbaDevice, lstTargets.toArray(new HostInternetScsiHbaStaticTarget[0]));
+		_hostStorageSystem.removeInternetScsiStaticTargets(iScsiHbaDevice, lstTargets.toArray(new HostInternetScsiHbaStaticTarget[0]));
 	}
 	
 	public void rescanHba(String iScsiHbaDevice) throws Exception {
-		_context.getService().rescanHba(_mor, iScsiHbaDevice);
+		_hostStorageSystem.rescanHba(iScsiHbaDevice);
 	}
 
     public void rescanVmfs() throws Exception {
-        _context.getService().rescanVmfs(_mor);
+        _hostStorageSystem.rescanVmfs();
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
index 4349d41..9b357e8 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HttpNfcLeaseMO.java
@@ -28,6 +28,7 @@ import org.apache.log4j.Logger;
 import org.w3c.dom.Element;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.HttpNfcLeaseInfo;
 import com.vmware.vim25.HttpNfcLeaseManifestEntry;
 import com.vmware.vim25.HttpNfcLeaseState;
@@ -37,16 +38,21 @@ import com.vmware.vim25.OvfCreateImportSpecResult;
 import com.vmware.vim25.OvfFileItem;
 import com.vmware.vim25.PropertyFilterSpec;
 import com.vmware.vim25.PropertySpec;
+import com.vmware.vim25.mo.HttpNfcLease;
 
 public class HttpNfcLeaseMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(HttpNfcLeaseMO.class);
+    
+    protected HttpNfcLease _httpNfcLease;
 
 	public HttpNfcLeaseMO(VmwareContext context, ManagedObjectReference morHttpNfcLease) {
 		super(context, morHttpNfcLease);
+		_httpNfcLease = new HttpNfcLease(context.getServerConnection(), morHttpNfcLease);
 	}
 
 	public HttpNfcLeaseMO(VmwareContext context, String morType, String morValue) {
 		super(context, morType, morValue);
+		_httpNfcLease = new HttpNfcLease(context.getServerConnection(), _mor);
 	}
 
 	public HttpNfcLeaseState getState() throws Exception {
@@ -84,15 +90,15 @@ public class HttpNfcLeaseMO extends BaseMO {
 	}
 
 	public HttpNfcLeaseManifestEntry[] getLeaseManifest() throws Exception {
-		return _context.getService().httpNfcLeaseGetManifest(_mor);
+		return _httpNfcLease.httpNfcLeaseGetManifest();
 	}
 
 	public void completeLease() throws Exception {
-		_context.getService().httpNfcLeaseComplete(_mor);
+		_httpNfcLease.httpNfcLeaseComplete();
 	}
 
 	public void abortLease() throws Exception {
-		_context.getService().httpNfcLeaseAbort(_mor, null);
+		_httpNfcLease.httpNfcLeaseAbort(null);
 	}
 
 	public void updateLeaseProgress(int percent) throws Exception {
@@ -102,7 +108,7 @@ public class HttpNfcLeaseMO extends BaseMO {
 		else if(percent > 100)
 			percent = 100;
 
-		_context.getService().httpNfcLeaseProgress(_mor, percent);
+		_httpNfcLease.httpNfcLeaseProgress(percent);
 	}
 
 	public ProgressReporter createProgressReporter() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
index 88ba4f1..1f8f54f 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -25,8 +25,10 @@ import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.lang.ArrayUtils;
 import org.apache.log4j.Logger;
 
+import com.vmware.vim25.AlreadyExists;
 import com.vmware.vim25.BoolPolicy;
 import com.vmware.vim25.CustomFieldStringValue;
 import com.vmware.vim25.DVPortSetting;
@@ -64,6 +66,10 @@ import com.vmware.vim25.VirtualSCSISharing;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchPvlanSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanIdSpec;
 import com.vmware.vim25.VmwareDistributedVirtualSwitchVlanSpec;
+import com.vmware.vim25.mo.HostSystem;
+import com.vmware.vim25.mo.HttpNfcLease;
+import com.vmware.vim25.mo.OvfManager;
+import com.vmware.vim25.mo.ResourcePool;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.hypervisor.vmware.util.VmwareHelper;
@@ -96,7 +102,7 @@ public class HypervisorHostHelper {
             for(ObjectContent oc : ocs) {
                 String vmNameInvCenter = null;
                 String vmInternalCSName = null;
-                List<DynamicProperty> objProps = oc.getPropSet();
+                DynamicProperty[] objProps = oc.getPropSet();
 		        if(objProps != null) {
 		            for(DynamicProperty objProp : objProps) {
 		                if(objProp.getName().equals("name")) {
@@ -130,7 +136,7 @@ public class HypervisorHostHelper {
         ObjectContent[] ocs = hyperHost.getDatastorePropertiesOnHyperHost(new String[] { "name"} );
         if(ocs != null && ocs.length > 0) {
             for(ObjectContent oc : ocs) {
-                List<DynamicProperty> objProps = oc.getPropSet();
+                DynamicProperty[] objProps = oc.getPropSet();
                 if(objProps != null) {
                     for(DynamicProperty objProp : objProps) {
                         if(objProp.getVal().toString().equals(datastoreName))
@@ -652,14 +658,16 @@ public class HypervisorHostHelper {
         // Next, add the required primary and secondary vlan config specs to the dvs config spec.
         if (!vlanmap.containsKey(vid)) {
             VMwareDVSPvlanConfigSpec ppvlanConfigSpec = createDVPortPvlanConfigSpec(vid, vid, PvlanType.promiscuous, PvlanOperation.add);
-            dvsSpec.getPvlanConfigSpec().add(ppvlanConfigSpec);
+            dvsSpec.setPvlanConfigSpec(
+                    (VMwareDVSPvlanConfigSpec[]) ArrayUtils.add(dvsSpec.getPvlanConfigSpec(), ppvlanConfigSpec));
         }
         if ( !vid.equals(spvlanid) && !vlanmap.containsKey(spvlanid)) {
             VMwareDVSPvlanConfigSpec spvlanConfigSpec = createDVPortPvlanConfigSpec(vid, spvlanid, PvlanType.isolated, PvlanOperation.add);
-            dvsSpec.getPvlanConfigSpec().add(spvlanConfigSpec);
+            dvsSpec.setPvlanConfigSpec(
+                    (VMwareDVSPvlanConfigSpec[]) ArrayUtils.add(dvsSpec.getPvlanConfigSpec(), spvlanConfigSpec));
         }
 
-        if (dvsSpec.getPvlanConfigSpec().size() > 0) {
+        if (dvsSpec.getPvlanConfigSpec().length > 0) {
             // We have something to configure on the DVS... so send it the command.
             // When reconfiguring a vmware DVSwitch, we need to send in the configVersion in the spec.
             // Let's retrieve this switch's configVersion first.
@@ -669,7 +677,7 @@ public class HypervisorHostHelper {
             // Reconfigure the dvs using this spec.
             try {
                 dvSwitchMo.updateVMWareDVSwitchGetTask(morDvSwitch, dvsSpec);
-            } catch (AlreadyExistsFaultMsg e) {
+            } catch (AlreadyExists e) {
                 s_logger.info("Specified vlan id (" + vid + ") private vlan id (" + spvlanid + ") tuple already configured on VMWare DVSwitch");
                 // Do nothing, good if the tuple's already configured on the dvswitch.
             } catch (Exception e) {
@@ -1006,14 +1014,14 @@ public class HypervisorHostHelper {
             ManagedObjectReference morParent = hostMo.getParentMor();
             if(morParent != null && morParent.getType().equals("ClusterComputeResource")) {
                 // to be conservative, lock cluster
-                GlobalLock lock = GlobalLock.getInternLock("ClusterLock." + morParent.getValue());
+                GlobalLock lock = GlobalLock.getInternLock("ClusterLock." + morParent.getVal());
                 try {
                     if(lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
                         try {
                             List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
                             if(hosts != null) {
                                 for(ManagedObjectReference otherHost: hosts) {
-                                    if(!otherHost.getValue().equals(hostMo.getMor().getValue())) {
+                                    if(!otherHost.getVal().equals(hostMo.getMor().getVal())) {
                                         HostMO otherHostMo = new HostMO(hostMo.getContext(), otherHost);
                                         try {
                                             if(s_logger.isDebugEnabled())
@@ -1063,7 +1071,7 @@ public class HypervisorHostHelper {
             return true;
 
         // so far policyInSpec and shapingPolicy should both not be null
-        if(policyInSpec.isEnabled() == null || !policyInSpec.isEnabled().booleanValue())
+        if(policyInSpec.getEnabled() == null || !policyInSpec.getEnabled().booleanValue())
             return false;
 
         if(policyInSpec.getAverageBandwidth() == null || policyInSpec.getAverageBandwidth().longValue() != shapingPolicy.getAverageBandwidth().longValue())
@@ -1154,12 +1162,12 @@ public class HypervisorHostHelper {
 
         // Scsi controller
         VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
-        scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
+        scsiController.setSharedBus(VirtualSCSISharing.noSharing);
         scsiController.setBusNumber(0);
         scsiController.setKey(1);
         VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
         scsiControllerSpec.setDevice(scsiController);
-        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
 
         VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
         DatastoreMO dsMo = new DatastoreMO(host.getContext(), morDs);
@@ -1172,10 +1180,9 @@ public class HypervisorHostHelper {
 
         VirtualDeviceConfigSpec videoDeviceSpec = new VirtualDeviceConfigSpec();
         videoDeviceSpec.setDevice(videoCard);
-        videoDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+        videoDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
 
-        vmConfig.getDeviceChange().add(scsiControllerSpec);
-        vmConfig.getDeviceChange().add(videoDeviceSpec);
+        vmConfig.setDeviceChange(new VirtualDeviceConfigSpec[] { scsiControllerSpec, videoDeviceSpec});
         if(host.createVm(vmConfig)) {
             // Here, when attempting to find the VM, we need to use the name
             // with which we created it. This is the only such place where
@@ -1218,20 +1225,20 @@ public class HypervisorHostHelper {
         vmConfig.setName(vmName);
         vmConfig.setMemoryMB((long) 4);
         vmConfig.setNumCPUs(1);
-        vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value());
+        vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.otherGuest.toString());
         VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo();
         fileInfo.setVmPathName(dsMo.getDatastoreRootPath());
         vmConfig.setFiles(fileInfo);
 
         VirtualLsiLogicController scsiController = new VirtualLsiLogicController();
-        scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING);
+        scsiController.setSharedBus(VirtualSCSISharing.noSharing);
         scsiController.setBusNumber(0);
         scsiController.setKey(1);
         VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec();
         scsiControllerSpec.setDevice(scsiController);
-        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+        scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
 
-        vmConfig.getDeviceChange().add(scsiControllerSpec);
+        vmConfig.setDeviceChange( new VirtualDeviceConfigSpec[] { scsiControllerSpec });
         if(hyperHost.createVm(vmConfig)) {
         	// Ugly work-around, it takes time for newly created VM to appear
         	for(int i = 0; i < 10 && workingVM == null; i++) {
@@ -1320,9 +1327,12 @@ public class HypervisorHostHelper {
 
         String ovfDescriptor = HttpNfcLeaseMO.readOvfContent(ovfFilePath);
         VmwareContext context = host.getContext();
-        OvfCreateImportSpecResult ovfImportResult = context.getService().createImportSpec(
-                context.getServiceContent().getOvfManager(), ovfDescriptor, morRp,
-                dsMo.getMor(), importSpecParams);
+        ResourcePool resourcePool = new ResourcePool(context.getServerConnection(), morRp);
+        HostSystem hostSystem = new HostSystem(context.getServerConnection(), morHost);
+        OvfManager ovfManager = context.getOvfManager();
+
+        OvfCreateImportSpecResult ovfImportResult = ovfManager.createImportSpec(ovfDescriptor, resourcePool,
+                dsMo._datastore, importSpecParams);
 
         if(ovfImportResult == null) {
             String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
@@ -1332,8 +1342,8 @@ public class HypervisorHostHelper {
         }
 
         DatacenterMO dcMo = new DatacenterMO(context, host.getHyperHostDatacenter());
-        ManagedObjectReference morLease = context.getService().importVApp(morRp,
-                ovfImportResult.getImportSpec(), dcMo.getVmFolder(), morHost);
+        HttpNfcLease lease = resourcePool.importVApp(ovfImportResult.getImportSpec(), dcMo._datacenter.getVmFolder(), hostSystem);
+        ManagedObjectReference morLease = lease.getMOR();
         if(morLease == null) {
             String msg = "importVApp() failed. ovfFilePath: " + ovfFilePath + ", vmName: "
                     + vmName + ", diskOption: " + diskOption;
@@ -1343,14 +1353,14 @@ public class HypervisorHostHelper {
         boolean importSuccess = true;
         final HttpNfcLeaseMO leaseMo = new HttpNfcLeaseMO(context, morLease);
         HttpNfcLeaseState state = leaseMo.waitState(
-                new HttpNfcLeaseState[] { HttpNfcLeaseState.READY, HttpNfcLeaseState.ERROR });
+                new HttpNfcLeaseState[] { HttpNfcLeaseState.ready, HttpNfcLeaseState.error });
         try {
-            if(state == HttpNfcLeaseState.READY) {
+            if(state == HttpNfcLeaseState.ready) {
                 final long totalBytes = HttpNfcLeaseMO.calcTotalBytes(ovfImportResult);
                 File ovfFile = new File(ovfFilePath);
 
                 HttpNfcLeaseInfo httpNfcLeaseInfo = leaseMo.getLeaseInfo();
-                List<HttpNfcLeaseDeviceUrl> deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
+                HttpNfcLeaseDeviceUrl[] deviceUrls = httpNfcLeaseInfo.getDeviceUrl();
                 long bytesAlreadyWritten = 0;
 
                 final HttpNfcLeaseMO.ProgressReporter progressReporter = leaseMo.createProgressReporter();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java
index bb8af0f..34cf973 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java
@@ -25,6 +25,7 @@ import com.vmware.vim25.KeyValue;
 import com.vmware.vim25.LicenseAssignmentManagerLicenseAssignment;
 import com.vmware.vim25.LicenseManagerLicenseInfo;
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.LicenseAssignmentManager;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 
@@ -35,17 +36,21 @@ public class LicenseAssignmentManagerMO extends BaseMO {
     private static final String LICENSE_INFO_PRODUCT_NAME = "ProductName";
     private static final String LICENSE_INFO_NAME = "Name";
     private static final String LICENSE_INFO_FEATURE = "feature";
+    
+    protected LicenseAssignmentManager _licenseAssingnmentManager;
 
     public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) {
         super(context, mor);
+        _licenseAssingnmentManager = new LicenseAssignmentManager(context.getServerConnection(), mor);
     }
 
     public LicenseAssignmentManagerMO(VmwareContext context, String morType, String morValue) {
         super(context, morType, morValue);
+        _licenseAssingnmentManager = new LicenseAssignmentManager(context.getServerConnection(), _mor);
     }
 
     public LicenseAssignmentManagerLicenseAssignment getAssignedLicenseToHost(ManagedObjectReference hostMor) throws Exception {
-        LicenseAssignmentManagerLicenseAssignment[] licenses = _context.getVimClient().getService().queryAssignedLicenses(_mor, hostMor.getVal());
+        LicenseAssignmentManagerLicenseAssignment[] licenses = _licenseAssingnmentManager.queryAssignedLicenses(hostMor.getVal());
         return licenses[0];
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
index df82f15..dc78134 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
@@ -19,19 +19,28 @@ package com.cloud.hypervisor.vmware.mo;
 import java.util.List;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.ManagedObjectReference;
+import com.vmware.vim25.mo.Network;
 
 public class NetworkMO extends BaseMO {
+    private Network network;
+    
     public NetworkMO(VmwareContext context, ManagedObjectReference morCluster) {
         super(context, morCluster);
+        network = new Network(context.getServerConnection(), morCluster);
     }
 
     public NetworkMO(VmwareContext context, String morType, String morValue) {
         super(context, morType, morValue);
+        ManagedObjectReference networkMor = new ManagedObjectReference();
+        networkMor.setType(morType);
+        networkMor.setVal(morValue);
+        network = new Network(context.getServerConnection(), networkMor);
     }
 
     public void destroyNetwork() throws Exception {
-        _context.getService().destroyNetwork(_mor);
+        network.destroyNetwork();
     }
 
     public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
index 35aa78c..497b0de 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
@@ -16,7 +16,6 @@
 // under the License.
 package com.cloud.hypervisor.vmware.mo;
 
-import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.List;
 
@@ -25,6 +24,7 @@ import javax.xml.datatype.DatatypeFactory;
 import javax.xml.datatype.XMLGregorianCalendar;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.PerfCompositeMetric;
 import com.vmware.vim25.PerfCounterInfo;
@@ -33,10 +33,10 @@ import com.vmware.vim25.PerfInterval;
 import com.vmware.vim25.PerfMetricId;
 import com.vmware.vim25.PerfProviderSummary;
 import com.vmware.vim25.PerfQuerySpec;
-
-import java.util.Arrays;
+import com.vmware.vim25.mo.ManagedEntity;
 
 public class PerfManagerMO extends BaseMO {
+    
     public PerfManagerMO(VmwareContext context, ManagedObjectReference mor) {
         super(context, mor);
     }
@@ -46,72 +46,44 @@ public class PerfManagerMO extends BaseMO {
     }
 
     public void createPerfInterval(PerfInterval interval) throws Exception {
-        _context.getService().createPerfInterval(_mor, interval);
-    }
-
-    /**
-     * Converts Calendar object into XMLGregorianCalendar
-     *
-     * @param calendar Object to be converted
-     * @return XMLGregorianCalendar
-     */
-    private XMLGregorianCalendar calendarToXMLGregorianCalendar(Calendar calendar) throws DatatypeConfigurationException {
-
-        DatatypeFactory dtf = DatatypeFactory.newInstance();
-        XMLGregorianCalendar xgc = dtf.newXMLGregorianCalendar();
-        xgc.setYear(calendar.get(Calendar.YEAR));
-        xgc.setMonth(calendar.get(Calendar.MONTH) + 1);
-        xgc.setDay(calendar.get(Calendar.DAY_OF_MONTH));
-        xgc.setHour(calendar.get(Calendar.HOUR_OF_DAY));
-        xgc.setMinute(calendar.get(Calendar.MINUTE));
-        xgc.setSecond(calendar.get(Calendar.SECOND));
-        xgc.setMillisecond(calendar.get(Calendar.MILLISECOND));
-
-        // Calendar ZONE_OFFSET and DST_OFFSET fields are in milliseconds.
-        int offsetInMinutes = (calendar.get(Calendar.ZONE_OFFSET) + calendar.get(Calendar.DST_OFFSET)) / (60 * 1000);
-        xgc.setTimezone(offsetInMinutes);
-        return xgc;
+        _context.getPerformanceManager().createPerfInterval(interval);
     }
 
-    public List<PerfMetricId> queryAvailablePerfMetric(ManagedObjectReference morEntity, Calendar beginTime,
+    public PerfMetricId[] queryAvailablePerfMetric(ManagedObjectReference morEntity, Calendar beginTime,
         Calendar endTime, Integer intervalId) throws Exception {
 
-        return _context.getService().queryAvailablePerfMetric(_mor, morEntity, calendarToXMLGregorianCalendar(beginTime),
-                calendarToXMLGregorianCalendar(endTime), intervalId);
+        ManagedEntity me = new ManagedEntity(_context.getServerConnection(), morEntity);
+        return _context.getPerformanceManager().queryAvailablePerfMetric(me, beginTime,
+                endTime, intervalId);
     }
 
     public PerfCompositeMetric queryPerfComposite(PerfQuerySpec spec) throws Exception {
-        return _context.getService().queryPerfComposite(_mor, spec);
+        return _context.getPerformanceManager().queryPerfComposite(spec);
     }
 
-    public List<PerfCounterInfo> queryPerfCounter(int[] counterId) throws Exception {
-        List<Integer> counterArr = new ArrayList<Integer>();
-        if ( counterId != null){
-            for (int i = 0; i < counterId.length; i++ ){
-                counterArr.add(counterId[i]);
-            }
-        }
-        return _context.getService().queryPerfCounter(_mor, counterArr);
+    public PerfCounterInfo[] queryPerfCounter(int[] counterId) throws Exception {
+        return _context.getPerformanceManager().queryPerfCounter(counterId);
     }
 
-    public List<PerfCounterInfo> queryPerfCounterByLevel(int level) throws Exception {
-        return _context.getService().queryPerfCounterByLevel(_mor, level);
+    public PerfCounterInfo[] queryPerfCounterByLevel(int level) throws Exception {
+        return _context.getPerformanceManager().queryPerfCounterByLevel(level);
     }
 
     public PerfProviderSummary queryPerfProviderSummary(ManagedObjectReference morEntity) throws Exception {
-        return _context.getService().queryPerfProviderSummary(_mor, morEntity);
+        ManagedEntity me = new ManagedEntity(_context.getServerConnection(), morEntity);
+        return _context.getPerformanceManager().queryPerfProviderSummary(me);
     }
 
-    public List<PerfEntityMetricBase> queryPerf(PerfQuerySpec[] specs) throws Exception {
-        return _context.getService().queryPerf(_mor, Arrays.asList(specs));
+    public PerfEntityMetricBase[] queryPerf(PerfQuerySpec[] specs) throws Exception {
+        return _context.getPerformanceManager().queryPerf(specs);
     }
 
     public void removePerfInterval(int samplePeriod) throws Exception {
-        _context.getService().removePerfInterval(_mor, samplePeriod);
+        _context.getPerformanceManager().removePerfInterval(samplePeriod);
     }
 
     public void updatePerfInterval(PerfInterval interval) throws Exception {
-        _context.getService().updatePerfInterval(_mor, interval);
+        _context.getPerformanceManager().updatePerfInterval(interval);
     }
 
     public List<PerfCounterInfo> getCounterInfo() throws Exception {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/TaskMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/TaskMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/TaskMO.java
index 694734b..3a1be30 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/TaskMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/TaskMO.java
@@ -17,19 +17,28 @@
 package com.cloud.hypervisor.vmware.mo;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.LocalizableMessage;
 import com.vmware.vim25.LocalizedMethodFault;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.TaskInfo;
 import com.vmware.vim25.TaskInfoState;
+import com.vmware.vim25.mo.Task;
 
 public class TaskMO extends BaseMO {
+    private Task task;
+    
     public TaskMO(VmwareContext context, ManagedObjectReference morTask) {
         super(context, morTask);
+        task = new Task(context.getServerConnection(), morTask);
     }
 
     public TaskMO(VmwareContext context, String morType, String morValue) {
         super(context, morType, morValue);
+        ManagedObjectReference morTask = new ManagedObjectReference();
+        morTask.setType(morType);
+        morTask.setVal(morValue);
+        task = new Task(context.getServerConnection(), morTask);
     }
 
     public TaskInfo getTaskInfo() throws Exception {
@@ -37,19 +46,19 @@ public class TaskMO extends BaseMO {
     }
 
     public void setTaskDescription(LocalizableMessage description) throws Exception {
-    	_context.getService().setTaskDescription(_mor, description);
+        task.setTaskDescription(description);
     }
 
     public void setTaskState(TaskInfoState state, Object result, LocalizedMethodFault fault) throws Exception {
-    	_context.getService().setTaskState(_mor, state, result, fault);
+        task.setTaskState(state, result, fault);
     }
 
     public void updateProgress(int percentDone) throws Exception {
-    	_context.getService().updateProgress(_mor, percentDone);
+        task.updateProgress(percentDone);
     }
 
     public void cancelTask() throws Exception {
-    	_context.getService().cancelTask(_mor);
+        task.cancelTask();
     }
 
     public static String getTaskFailureInfo(VmwareContext context, ManagedObjectReference morTask) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/67fc53ab/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java
index bc608e8..101aed0 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java
@@ -19,12 +19,17 @@ package com.cloud.hypervisor.vmware.mo;
 import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.util.VmwareContext;
+
 import com.vmware.vim25.HostDiskDimensionsChs;
 import com.vmware.vim25.ManagedObjectReference;
 import com.vmware.vim25.VirtualDiskSpec;
+import com.vmware.vim25.mo.Datacenter;
+import com.vmware.vim25.mo.Task;
+import com.vmware.vim25.mo.VirtualDiskManager;
 
 public class VirtualDiskManagerMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
+    protected VirtualDiskManager _virtualDiskManager;
 
     public VirtualDiskManagerMO(VmwareContext context) {
             super(context, context.getServiceContent().getVirtualDiskManager());
@@ -41,8 +46,11 @@ public class VirtualDiskManagerMO extends BaseMO {
     public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc,
     	String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec,
     	boolean force) throws Exception {
+        Datacenter sourceDatacenter = new Datacenter(_context.getServerConnection(), morSrcDc);
+        Datacenter destinationDatacenter = new Datacenter(_context.getServerConnection(), morDestDc);
 
-    	ManagedObjectReference morTask = _context.getService().copyVirtualDisk_Task(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);
+        Task task = _virtualDiskManager.copyVirtualDisk_Task(srcName, sourceDatacenter, destName, destinationDatacenter, diskSpec, force);
+    	ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -53,7 +61,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void createVirtualDisk(String name, ManagedObjectReference morDc, VirtualDiskSpec diskSpec) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().createVirtualDisk_Task(_mor, name, morDc, diskSpec);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.createVirtualDisk_Task(name, datacenter, diskSpec);
+    	ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -64,7 +74,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void defragmentVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().defragmentVirtualDisk_Task(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.defragmentVirtualDisk_Task(name, datacenter);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -74,7 +86,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void deleteVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().deleteVirtualDisk_Task(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.deleteVirtualDisk_Task(name, datacenter);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -84,7 +98,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void eagerZeroVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().eagerZeroVirtualDisk_Task(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.eagerZeroVirtualDisk_Task(name, datacenter);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -94,7 +110,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void extendVirtualDisk(String name, ManagedObjectReference morDc, long newCapacityKb, boolean eagerZero) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().extendVirtualDisk_Task(_mor, name, morDc, newCapacityKb, eagerZero);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.extendVirtualDisk_Task(name, datacenter, newCapacityKb, eagerZero);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -104,7 +122,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void inflateVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().inflateVirtualDisk_Task(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.inflateVirtualDisk_Task(name, datacenter);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -113,7 +133,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void shrinkVirtualDisk(String name, ManagedObjectReference morDc, boolean copy) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().shrinkVirtualDisk_Task(_mor, name, morDc, copy);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.shrinkVirtualDisk_Task(name, datacenter, copy);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -122,7 +144,9 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public void zeroFillVirtualDisk(String name, ManagedObjectReference morDc) throws Exception {
-    	ManagedObjectReference morTask = _context.getService().zeroFillVirtualDisk_Task(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);
+        Task task = _virtualDiskManager.zeroFillVirtualDisk_Task(name, datacenter);
+        ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -132,9 +156,11 @@ public class VirtualDiskManagerMO extends BaseMO {
 
     public void moveVirtualDisk(String srcName, ManagedObjectReference morSrcDc,
     	String destName, ManagedObjectReference morDestDc, boolean force) throws Exception {
-
-    	ManagedObjectReference morTask = _context.getService().moveVirtualDisk_Task(_mor, srcName, morSrcDc,
-    		destName, morDestDc, force);
+        Datacenter sourceDatacenter = new Datacenter(_context.getServerConnection(), morSrcDc);
+        Datacenter destinationDatacenter = new Datacenter(_context.getServerConnection(), morDestDc);
+        Task task = _virtualDiskManager.moveVirtualDisk_Task(srcName, sourceDatacenter, destName, destinationDatacenter, force);
+                
+    	ManagedObjectReference morTask = task.getMOR();
 
 		boolean result = _context.getVimClient().waitForTask(morTask);
 		if(!result)
@@ -144,18 +170,22 @@ public class VirtualDiskManagerMO extends BaseMO {
     }
 
     public int queryVirtualDiskFragmentation(String name, ManagedObjectReference morDc) throws Exception {
-    	return _context.getService().queryVirtualDiskFragmentation(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);        
+    	return _virtualDiskManager.queryVirtualDiskFragmentation(name, datacenter);
     }
 
     public HostDiskDimensionsChs queryVirtualDiskGeometry(String name, ManagedObjectReference morDc) throws Exception {
-    	return _context.getService().queryVirtualDiskGeometry(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);        
+        return _virtualDiskManager.queryVirtualDiskGeometry(name, datacenter);
     }
 
     public String queryVirtualDiskUuid(String name, ManagedObjectReference morDc) throws Exception {
-    	return _context.getService().queryVirtualDiskUuid(_mor, name, morDc);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);        
+        return _virtualDiskManager.queryVirtualDiskUuid(name, datacenter);
     }
 
     public void setVirtualDiskUuid(String name, ManagedObjectReference morDc, String uuid) throws Exception {
-    	_context.getService().setVirtualDiskUuid(_mor, name, morDc, uuid);
+        Datacenter datacenter = new Datacenter(_context.getServerConnection(), morDc);        
+        _virtualDiskManager.setVirtualDiskUuid(name, datacenter, uuid);
     }
 }


Mime
View raw message