cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [13/40] git commit: refs/heads/master - Fix cast error from List<?> to array.
Date Tue, 05 Mar 2013 02:09:46 GMT
Fix cast error from List<?> to array.

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

Branch: refs/heads/master
Commit: 1ce4d62ace9ffd5976eda30652ada78a89fdae80
Parents: b9cf5c2
Author: Min Chen <min.chen@citrix.com>
Authored: Tue Feb 5 21:44:38 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue Feb 5 21:44:38 2013 -0800

----------------------------------------------------------------------
 .../vmware/manager/VmwareManagerImpl.java          |   12 ++--
 .../vmware/resource/VmwareContextFactory.java      |   17 ++++-
 .../hypervisor/vmware/resource/VmwareResource.java |   14 ++--
 .../com/cloud/hypervisor/vmware/mo/ClusterMO.java  |   18 +++---
 .../vmware/mo/CustomFieldsManagerMO.java           |    8 ++-
 .../vmware/mo/HostDatastoreSystemMO.java           |   12 ++--
 .../src/com/cloud/hypervisor/vmware/mo/HostMO.java |   48 +++++++--------
 .../hypervisor/vmware/mo/HypervisorHostHelper.java |    2 +-
 .../com/cloud/hypervisor/vmware/mo/NetworkMO.java  |    7 +-
 .../cloud/hypervisor/vmware/mo/PerfManagerMO.java  |    8 +-
 .../hypervisor/vmware/mo/VirtualMachineMO.java     |   10 ++--
 .../cloud/hypervisor/vmware/util/VmwareClient.java |    3 +-
 .../vmware/mo/TestVmwareContextFactory.java        |   14 ++--
 .../cloud/hypervisor/vmware/mo/TestVmwareMO.java   |    1 -
 vmware-base/test/com/cloud/vmware/TestVMWare.java  |    1 -
 15 files changed, 92 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 24c89d3..21cd914 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
@@ -390,20 +390,20 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager,
Vmw
             List<ManagedObjectReference> returnedHostList = new ArrayList<ManagedObjectReference>();
 
             if(mor.getType().equals("ComputeResource")) {
-                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getVimClient().getDynamicProperty(mor,
"host");
-                assert(hosts != null);
+                List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)serviceContext.getVimClient().getDynamicProperty(mor,
"host");
+                assert(hosts != null && hosts.size() > 0);
 
                 // For ESX host, we need to enable host firewall to allow VNC access
-                HostMO hostMo = new HostMO(serviceContext, hosts[0]);
+                HostMO hostMo = new HostMO(serviceContext, hosts.get(0));
 
                 prepareHost(hostMo, privateTrafficLabel);
-                returnedHostList.add(hosts[0]);
+                returnedHostList.add(hosts.get(0));
                 return returnedHostList;
             } else if(mor.getType().equals("ClusterComputeResource")) {
-                ManagedObjectReference[] hosts = (ManagedObjectReference[])serviceContext.getVimClient().getDynamicProperty(mor,
"host");
+                List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)serviceContext.getVimClient().getDynamicProperty(mor,
"host");
                 assert(hosts != null);
 
-                if(hosts.length > _maxHostsPerCluster) {
+                if(hosts.size() > _maxHostsPerCluster) {
                     String msg = "vCenter cluster size is too big (current configured cluster
size: " + _maxHostsPerCluster + ")";
                     s_logger.error(msg);
                     throw new DiscoveredWithErrorException(msg);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
index 20399cd..5db9da3 100755
--- a/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
+++ b/plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareContextFactory.java
@@ -16,16 +16,18 @@
 // under the License.
 package com.cloud.hypervisor.vmware.resource;
 
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+
 import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
 
 import com.cloud.hypervisor.vmware.manager.VmwareManager;
-import com.cloud.hypervisor.vmware.manager.VmwareManagerImpl;
 import com.cloud.hypervisor.vmware.util.VmwareClient;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.cloud.utils.StringUtils;
-import com.cloud.utils.component.ComponentContext;
-
 
+@Component
 public class VmwareContextFactory {
 
     private static final Logger s_logger = Logger.getLogger(VmwareContextFactory.class);
@@ -33,10 +35,17 @@ public class VmwareContextFactory {
 	private static volatile int s_seq = 1;
 	private static VmwareManager s_vmwareMgr;
 
+	@Inject VmwareManager _vmwareMgr;
+
 	static {
 		// skip certificate check
 		System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
-		s_vmwareMgr = ComponentContext.inject(VmwareManagerImpl.class);
+		//s_vmwareMgr = ComponentContext.inject(VmwareManagerImpl.class);
+	}
+
+	@PostConstruct
+	void init() {
+	    s_vmwareMgr = _vmwareMgr;
 	}
 
 	public static VmwareContext create(String vCenterAddress, String vCenterUserName, String
vCenterPassword) throws Exception {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 397408a..7b97d3d 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
@@ -4494,14 +4494,14 @@ public class VmwareResource implements StoragePoolResource, ServerResource,
Vmwa
         PerfCounterInfo rxPerfCounterInfo = null;
         PerfCounterInfo txPerfCounterInfo = null;
 
-        PerfCounterInfo[] cInfo = (PerfCounterInfo[]) getServiceContext().getVimClient().getDynamicProperty(perfMgr,
"perfCounter");
-        for(int i=0; i<cInfo.length; ++i) {
-            if ("net".equalsIgnoreCase(cInfo[i].getGroupInfo().getKey())) {
-                if ("transmitted".equalsIgnoreCase(cInfo[i].getNameInfo().getKey())) {
-                    txPerfCounterInfo = cInfo[i];
+        List<PerfCounterInfo> cInfo = (List<PerfCounterInfo>) getServiceContext().getVimClient().getDynamicProperty(perfMgr,
"perfCounter");
+        for(PerfCounterInfo info : cInfo) {
+            if ("net".equalsIgnoreCase(info.getGroupInfo().getKey())) {
+                if ("transmitted".equalsIgnoreCase(info.getNameInfo().getKey())) {
+                    txPerfCounterInfo = info;
                 }
-                if ("received".equalsIgnoreCase(cInfo[i].getNameInfo().getKey())) {
-                    rxPerfCounterInfo = cInfo[i];
+                if ("received".equalsIgnoreCase(info.getNameInfo().getKey())) {
+                    rxPerfCounterInfo = info;
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 1026554..d112c34 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java
@@ -295,8 +295,8 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost
{
 
 		ManagedObjectReference morDs = null;
 		ManagedObjectReference morDsFirst = null;
-		ManagedObjectReference[] hosts = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(_mor,
"host");
-		if(hosts != null && hosts.length > 0) {
+		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor,
"host");
+		if(hosts != null && hosts.size() > 0) {
 			for(ManagedObjectReference morHost : hosts) {
 				HostMO hostMo = new HostMO(_context, morHost);
 				morDs = hostMo.mountDatastore(vmfsDatastore, poolHostAddress, poolHostPort, poolPath,
poolUuid);
@@ -328,8 +328,8 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost
{
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue()
+ ", poolUuid: " + poolUuid);
 
-		ManagedObjectReference[] hosts = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(_mor,
"host");
-		if(hosts != null && hosts.length > 0) {
+		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor,
"host");
+		if(hosts != null && hosts.size() > 0) {
 			for(ManagedObjectReference morHost : hosts) {
 				HostMO hostMo = new HostMO(_context, morHost);
 				hostMo.unmountDatastore(poolUuid);
@@ -473,8 +473,8 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost
{
 
 		// TODO, need to use traversal to optimize retrieve of
 		int cpuNumInCpuThreads = 1;
-		ManagedObjectReference[] hosts = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(_mor,
"host");
-		if(hosts != null && hosts.length > 0) {
+		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor,
"host");
+		if(hosts != null && hosts.size() > 0) {
 			for(ManagedObjectReference morHost : hosts) {
 				HostMO hostMo = new HostMO(_context, morHost);
 				HostHardwareSummary hardwareSummary = hostMo.getHostHardwareSummary();
@@ -498,9 +498,9 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost
{
 	    if(s_logger.isTraceEnabled())
 			s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue()
+ ", mgmtPortgroup: " + esxServiceConsolePort);
 
-		ManagedObjectReference[] hosts = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(_mor,
"host");
-		if(hosts != null && hosts.length > 0) {
-			VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts[0]).getHyperHostNetworkSummary(esxServiceConsolePort);
+		List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor,
"host");
+		if(hosts != null && hosts.size() > 0) {
+			VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort);
 
 		    if(s_logger.isTraceEnabled())
 				s_logger.trace("vCenter API trace - getHyperHostResourceSummary() done(successfully)");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 08932c5..3082a71 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java
@@ -16,6 +16,8 @@
 // under the License.
 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;
@@ -48,12 +50,12 @@ public class CustomFieldsManagerMO extends BaseMO {
 		_context.getService().setField(getMor(), morEntity, key, value);
 	}
 
-	public CustomFieldDef[] getFields() throws Exception {
-		return (CustomFieldDef[])_context.getVimClient().getDynamicProperty(getMor(), "field");
+	public List<CustomFieldDef> getFields() throws Exception {
+		return (List<CustomFieldDef>)_context.getVimClient().getDynamicProperty(getMor(),
"field");
 	}
 
 	public int getCustomFieldKey(String morType, String fieldName) throws Exception {
-		CustomFieldDef[] fields = getFields();
+		List<CustomFieldDef> fields = getFields();
 		if(fields != null) {
 			for(CustomFieldDef field : fields) {
 				if(field.getName().equals(fieldName) && field.getManagedObjectType().equals(morType))

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 7d967a9..3dcd724 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java
@@ -78,8 +78,8 @@ public class HostDatastoreSystemMO extends BaseMO {
 	public ManagedObjectReference findDatastoreByUrl(String storeUrl) throws Exception {
 		assert(storeUrl != null);
 
-		ManagedObjectReference[] datastores = getDatastores();
-		if(datastores != null && datastores.length > 0) {
+		List<ManagedObjectReference> datastores = getDatastores();
+		if(datastores != null && datastores.size() > 0) {
 			for(ManagedObjectReference morDatastore : datastores) {
 				NasDatastoreInfo info = getNasDatastoreInfo(morDatastore);
 				if(info != null) {
@@ -99,8 +99,8 @@ public class HostDatastoreSystemMO extends BaseMO {
 	public ManagedObjectReference findDatastoreByExportPath(String exportPath) throws Exception
{
 		assert(exportPath != null);
 
-		ManagedObjectReference[] datastores = getDatastores();
-		if(datastores != null && datastores.length > 0) {
+		List<ManagedObjectReference> datastores = getDatastores();
+		if(datastores != null && datastores.size() > 0) {
 			for(ManagedObjectReference morDatastore : datastores) {
 				DatastoreMO dsMo = new DatastoreMO(_context, morDatastore);
 				if(dsMo.getInventoryPath().equals(exportPath))
@@ -145,8 +145,8 @@ public class HostDatastoreSystemMO extends BaseMO {
 		return _context.getService().createNasDatastore(_mor, spec);
 	}
 
-	public ManagedObjectReference[] getDatastores() throws Exception {
-		return (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(
+	public List<ManagedObjectReference> getDatastores() throws Exception {
+		return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(
 			_mor, "datastore");
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 c164cc2..d806802 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java
@@ -84,16 +84,14 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		return (HostConfigManager)_context.getVimClient().getDynamicProperty(_mor, "configManager");
 	}
 
-	public VirtualNicManagerNetConfig[] getHostVirtualNicManagerNetConfig() throws Exception
{
-		VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[])_context.getVimClient().getDynamicProperty(_mor,
+	public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws
Exception {
+		return (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor,
 			"config.virtualNicManagerInfo.netConfig");
-		return netConfigs;
 	}
 
-	public HostIpRouteEntry[] getHostIpRouteEntries() throws Exception {
-		HostIpRouteEntry[] entries = (HostIpRouteEntry[])_context.getVimClient().getDynamicProperty(_mor,
+	public List<HostIpRouteEntry> getHostIpRouteEntries() throws Exception {
+		return (List<HostIpRouteEntry>)_context.getVimClient().getDynamicProperty(_mor,
 			"config.network.routeTableInfo.ipRoute");
-		return entries;
 	}
 
 	public HostListSummaryQuickStats getHostQuickStats() throws Exception {
@@ -142,7 +140,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 	@Override
 	public String getHyperHostDefaultGateway() throws Exception {
-		HostIpRouteEntry[] entries = getHostIpRouteEntries();
+		List<HostIpRouteEntry> entries = getHostIpRouteEntries();
 		for(HostIpRouteEntry entry : entries) {
 			if(entry.getNetwork().equalsIgnoreCase("0.0.0.0"))
 				return entry.getGateway();
@@ -222,7 +220,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	}
 
 	public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
-		ManagedObjectReference[] datastores = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(
+		List<ManagedObjectReference> datastores = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(
 			_mor, "datastore");
 		List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
 		if(datastores != null) {
@@ -236,7 +234,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	}
 
 	public HostVirtualSwitch getHostVirtualSwitchByName(String name) throws Exception {
-		HostVirtualSwitch[] switches = (HostVirtualSwitch[])_context.getVimClient().getDynamicProperty(
+		List<HostVirtualSwitch> switches = (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(
 			_mor, "config.network.vswitch");
 
 		if(switches != null) {
@@ -248,8 +246,8 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		return null;
 	}
 
-	public HostVirtualSwitch[] getHostVirtualSwitch() throws Exception {
-		return (HostVirtualSwitch[])_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
+	public List<HostVirtualSwitch> getHostVirtualSwitch() throws Exception {
+		return (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor,
"config.network.vswitch");
 	}
 
 	public AboutInfo getHostAboutInfo() throws Exception {
@@ -285,7 +283,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 
 	public HostVirtualSwitch getVirtualSwitchByName(String vSwitchName) throws Exception {
 
-		HostVirtualSwitch[] vSwitchs = getHostVirtualSwitch();
+		List<HostVirtualSwitch> vSwitchs = getHostVirtualSwitch();
 		if(vSwitchs != null) {
 			for(HostVirtualSwitch vSwitch: vSwitchs) {
 				if(vSwitch.getName().equals(vSwitchName))
@@ -327,7 +325,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	public String getPortGroupNameByNicType(HostVirtualNicType nicType) throws Exception {
 		assert(nicType != null);
 
-		VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[])_context.getVimClient().getDynamicProperty(_mor,
+		List<VirtualNicManagerNetConfig> netConfigs = (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor,
 			"config.virtualNicManagerInfo.netConfig");
 
 		if(netConfigs != null) {
@@ -448,10 +446,10 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	    return null;
 	}
 
-	public ManagedObjectReference[] getVmMorsOnNetwork(String portGroupName) throws Exception
{
+	public List<ManagedObjectReference> getVmMorsOnNetwork(String portGroupName) throws
Exception {
 		ManagedObjectReference morNetwork = getNetworkMor(portGroupName);
 		if(morNetwork != null)
-			return (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(morNetwork,
"vm");
+			return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(morNetwork,
"vm");
 		return null;
 	}
 
@@ -703,7 +701,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 	public ManagedObjectReference getExistingDataStoreOnHost(boolean vmfsDatastore, String hostAddress,
 			int hostPort, String path, String uuid, HostDatastoreSystemMO hostDatastoreSystemMo) {
 		// First retrieve the list of Datastores on the host.
-		ManagedObjectReference[] morArray;
+		List<ManagedObjectReference> morArray;
 		try {
 			morArray = hostDatastoreSystemMo.getDatastores();
 		} catch (Exception e) {
@@ -711,17 +709,17 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 			return null;
 		}
 		// Next, get all the NAS datastores from this array of datastores.
-		if (morArray.length > 0) {
+		if (morArray.size() > 0) {
 			int i;
-			for (i = 0; i < morArray.length; i++) {
+			for (i = 0; i < morArray.size(); i++) {
 				NasDatastoreInfo nasDS;
 				try {
-					nasDS = hostDatastoreSystemMo.getNasDatastoreInfo(morArray[i]);
+					nasDS = hostDatastoreSystemMo.getNasDatastoreInfo(morArray.get(i));
 					if (nasDS != null) {
 						//DatastoreInfo info = (DatastoreInfo)_context.getServiceUtil().getDynamicProperty(morDatastore,
"info");
 						if (nasDS.getNas().getRemoteHost().equalsIgnoreCase(hostAddress) &&
 								nasDS.getNas().getRemotePath().equalsIgnoreCase(path)) {
-							return morArray[i];
+							return morArray.get(i);
 						}
 					}
 				}  catch (Exception e) {
@@ -861,13 +859,13 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 		VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
 
 		if(this.getHostType() == VmwareHostType.ESXi) {
-			VirtualNicManagerNetConfig[] netConfigs = (VirtualNicManagerNetConfig[])_context.getVimClient().getDynamicProperty(_mor,
+			List<VirtualNicManagerNetConfig> netConfigs = (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor,
 				"config.virtualNicManagerInfo.netConfig");
 			assert(netConfigs != null);
 
-			for(int i = 0; i < netConfigs.length; i++) {
-				if(netConfigs[i].getNicType().equals("management")) {
-					for(HostVirtualNic nic : netConfigs[i].getCandidateVnic()) {
+			for(VirtualNicManagerNetConfig netConfig : netConfigs) {
+				if(netConfig.getNicType().equals("management")) {
+					for(HostVirtualNic nic : netConfig.getCandidateVnic()) {
 						if(nic.getPortgroup().equals(managementPortGroup)) {
 							summary.setHostIp(nic.getSpec().getIp().getIpAddress());
 							summary.setHostNetmask(nic.getSpec().getIp().getSubnetMask());
@@ -882,7 +880,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
 			}
 		} else {
 			// try with ESX path
-			HostVirtualNic[] hostVNics = (HostVirtualNic[])_context.getVimClient().getDynamicProperty(_mor,
+			List<HostVirtualNic> hostVNics = (List<HostVirtualNic>)_context.getVimClient().getDynamicProperty(_mor,
 				"config.network.consoleVnic");
 
 			if(hostVNics != null) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 abc391f..e4a9485 100755
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java
@@ -625,7 +625,7 @@ public class HypervisorHostHelper {
                 try {
                     if(lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
                         try {
-                            ManagedObjectReference[] hosts = (ManagedObjectReference[])hostMo.getContext().getVimClient().getDynamicProperty(morParent,
"host");
+                            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()))
{

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 b8e3ab4..df82f15 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java
@@ -16,6 +16,8 @@
 // under the License.
 package com.cloud.hypervisor.vmware.mo;
 
+import java.util.List;
+
 import com.cloud.hypervisor.vmware.util.VmwareContext;
 import com.vmware.vim25.ManagedObjectReference;
 
@@ -32,8 +34,7 @@ public class NetworkMO extends BaseMO {
         _context.getService().destroyNetwork(_mor);
     }
 
-    public ManagedObjectReference[] getVMsOnNetwork() throws Exception {
-        ManagedObjectReference[] vms = (ManagedObjectReference[])_context.getVimClient().getDynamicProperty(_mor,
"vm");
-        return vms;
+    public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {
+        return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor,
"vm");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/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 6c2b7bb..bb4fb56 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java
@@ -114,11 +114,11 @@ public class PerfManagerMO extends BaseMO {
         _context.getService().updatePerfInterval(_mor, interval);
     }
 
-    public PerfCounterInfo[] getCounterInfo() throws Exception {
-        return (PerfCounterInfo[])_context.getVimClient().getDynamicProperty(_mor, "perfCounter");
+    public List<PerfCounterInfo> getCounterInfo() throws Exception {
+        return (List<PerfCounterInfo>)_context.getVimClient().getDynamicProperty(_mor,
"perfCounter");
     }
 
-    public PerfInterval[] getIntervalInfo() throws Exception {
-        return (PerfInterval[])_context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
+    public List<PerfInterval> getIntervalInfo() throws Exception {
+        return (List<PerfInterval>)_context.getVimClient().getDynamicProperty(_mor,
"historicalInterval");
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index 76072cd..6f836c4 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -1716,13 +1716,13 @@ public class VirtualMachineMO extends BaseMO {
 
 	// return pair of VirtualDisk and disk device bus name(ide0:0, etc)
 	public Pair<VirtualDisk, String> getDiskDevice(String vmdkDatastorePath, boolean matchExactly)
throws Exception {
-		VirtualDevice[] devices = (VirtualDevice[])_context.getVimClient().getDynamicProperty(_mor,
"config.hardware.device");
+		List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor,
"config.hardware.device");
 
 		s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
 		DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
 		String srcBaseName = dsSrcFile.getFileBaseName();
 
-		if(devices != null && devices.length > 0) {
+		if(devices != null && devices.size() > 0) {
 			for(VirtualDevice device : devices) {
 				if(device instanceof VirtualDisk) {
 					s_logger.info("Test against disk device, controller key: " + device.getControllerKey()
+ ", unit number: " + device.getUnitNumber());
@@ -1837,7 +1837,7 @@ public class VirtualMachineMO extends BaseMO {
 		return pathList;
 	}
 
-	private String getDeviceBusName(VirtualDevice[] allDevices, VirtualDevice theDevice) throws
Exception {
+	private String getDeviceBusName(List<VirtualDevice> allDevices, VirtualDevice theDevice)
throws Exception {
 		for(VirtualDevice device : allDevices) {
 			if(device.getKey() == theDevice.getControllerKey().intValue()) {
 				if(device instanceof VirtualIDEController) {
@@ -1854,8 +1854,8 @@ public class VirtualMachineMO extends BaseMO {
 
 	public VirtualDisk[] getAllDiskDevice() throws Exception {
 		List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
-		VirtualDevice[] devices = (VirtualDevice[])_context.getVimClient().getDynamicProperty(_mor,
"config.hardware.device");
-		if(devices != null && devices.length > 0) {
+		List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor,
"config.hardware.device");
+		if(devices != null && devices.size() > 0) {
 			for(VirtualDevice device : devices) {
 				if(device instanceof VirtualDisk) {
 					deviceList.add((VirtualDisk)device);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
index 3fbe5c8..2e0238d 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java
@@ -97,6 +97,7 @@ public class VmwareClient {
 
         ctxt.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url);
         ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
+        ctxt.put("com.sun.xml.internal.ws.request.timeout", 60000);
 
         serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
         vimPort.login(serviceContent.getSessionManager(), userName, password, null);
@@ -177,7 +178,7 @@ public class VmwareClient {
                  */
                 Class dpCls = propertyValue.getClass();
                 String dynamicPropertyName = dpCls.getName();
-                if (dynamicPropertyName.startsWith("ArrayOf")) {
+                if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
                     String methodName = "get"
                             + dynamicPropertyName
                                     .substring(dynamicPropertyName.indexOf("ArrayOf") + "ArrayOf".length(),
dynamicPropertyName.length());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java
----------------------------------------------------------------------
diff --git a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java
b/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java
index a857986..81a62d2 100644
--- a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java
+++ b/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareContextFactory.java
@@ -16,12 +16,13 @@
 // under the License.
 package com.cloud.hypervisor.vmware.mo;
 
+import com.cloud.hypervisor.vmware.util.VmwareClient;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.vmware.apputils.version.ExtendedAppUtil;
+
 
 public class TestVmwareContextFactory {
 	private static volatile int s_seq = 1;
-	
+
 	static {
 		// skip certificate check
 		System.setProperty("axis.socketSecureFactory", "org.apache.axis.components.net.SunFakeTrustSocketFactory");
@@ -33,11 +34,10 @@ public class TestVmwareContextFactory {
 		assert(vCenterPassword != null);
 
 		String serviceUrl = "https://" + vCenterAddress + "/sdk/vimService";
-		String[] params = new String[] {"--url", serviceUrl, "--username", vCenterUserName, "--password",
vCenterPassword };
-		ExtendedAppUtil appUtil = ExtendedAppUtil.initialize(vCenterAddress + "-" + s_seq++, params);
-		
-		appUtil.connect();
-		VmwareContext context = new VmwareContext(appUtil, vCenterAddress);
+        VmwareClient vimClient = new VmwareClient(vCenterAddress + "-" + s_seq++);
+        vimClient.connect(serviceUrl, vCenterUserName, vCenterPassword);
+
+        VmwareContext context = new VmwareContext(vimClient, vCenterAddress);
 		return context;
 	}
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareMO.java b/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareMO.java
index 2417ddf9..c9807f4 100644
--- a/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareMO.java
+++ b/vmware-base/test/com/cloud/hypervisor/vmware/mo/TestVmwareMO.java
@@ -22,7 +22,6 @@ import org.apache.log4j.Logger;
 
 import com.cloud.hypervisor.vmware.mo.SnapshotDescriptor.SnapshotInfo;
 import com.cloud.hypervisor.vmware.util.VmwareContext;
-import com.cloud.serializer.GsonHelper;
 import com.cloud.utils.Pair;
 import com.cloud.utils.testcase.Log4jEnabledTestCase;
 import com.google.gson.Gson;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1ce4d62a/vmware-base/test/com/cloud/vmware/TestVMWare.java
----------------------------------------------------------------------
diff --git a/vmware-base/test/com/cloud/vmware/TestVMWare.java b/vmware-base/test/com/cloud/vmware/TestVMWare.java
index 43c784c..b0ec68d 100644
--- a/vmware-base/test/com/cloud/vmware/TestVMWare.java
+++ b/vmware-base/test/com/cloud/vmware/TestVMWare.java
@@ -37,7 +37,6 @@ import javax.net.ssl.SSLSession;
 import org.apache.log4j.xml.DOMConfigurator;
 
 import com.cloud.utils.PropertiesUtil;
-import com.vmware.apputils.version.ExtendedAppUtil;
 import com.vmware.vim25.HostIpConfig;
 import com.vmware.vim25.HostVirtualNicSpec;
 import com.vmware.vim25.HostConfigManager;


Mime
View raw message