mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Fix cast error from List<?> to array.
This commit is contained in:
parent
b9cf5c2147
commit
1ce4d62ace
@ -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);
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)");
|
||||
|
||||
@ -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))
|
||||
|
||||
@ -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");
|
||||
}
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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())) {
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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());
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user