Get rid of compiler warnings in vmware-base

This commit is contained in:
Hugo Trippaers 2014-01-22 09:34:46 +01:00
parent 86124138a1
commit b20add810e
18 changed files with 174 additions and 197 deletions

View File

@ -125,7 +125,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
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));
new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("VirtualMachine");
@ -164,7 +164,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
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));
new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
@ -196,7 +196,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
private ObjectContent[] getHostPropertiesOnCluster(String[] propertyPaths) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - retrieveProperties() on Host properties. target MOR: " + _mor.getValue() + ", properties: " +
new Gson().toJson(propertyPaths));
new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("HostSystem");
@ -257,7 +257,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
public void importVmFromOVF(String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - importVmFromOVF(). target MOR: " + _mor.getValue() + ", ovfFilePath: " + ovfFilePath + ", vmName: " + vmName +
", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);
", datastore: " + dsMo.getMor().getValue() + ", diskOption: " + diskOption);
ManagedObjectReference morRp = getHyperHostOwnerResourcePool();
assert (morRp != null);
@ -273,16 +273,16 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
@Override
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
int memoryReserveMB, 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 + ", cpuSpeedMhz: " +
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
boolean result =
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
guestOsIdentifier, morDs, snapshotDirToParent);
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
guestOsIdentifier, morDs, snapshotDirToParent);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - createBlankVm() done");
@ -295,11 +295,11 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
ManagedObjectReference morDs = null;
ManagedObjectReference morDsFirst = null;
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -332,7 +332,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - unmountDatastore(). target MOR: " + _mor.getValue() + ", poolUuid: " + poolUuid);
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -480,7 +480,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
// TODO, need to use traversal to optimize retrieve of
int cpuNumInCpuThreads = 1;
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
for (ManagedObjectReference morHost : hosts) {
HostMO hostMo = new HostMO(_context, morHost);
@ -505,7 +505,7 @@ public class ClusterMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - getHyperHostNetworkSummary(). target MOR: " + _mor.getValue() + ", mgmtPortgroup: " + esxServiceConsolePort);
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "host");
List<ManagedObjectReference> hosts = _context.getVimClient().getDynamicProperty(_mor, "host");
if (hosts != null && hosts.size() > 0) {
VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort);

View File

@ -51,7 +51,7 @@ public class CustomFieldsManagerMO extends BaseMO {
}
public List<CustomFieldDef> getFields() throws Exception {
return (List<CustomFieldDef>)_context.getVimClient().getDynamicProperty(getMor(), "field");
return _context.getVimClient().getDynamicProperty(getMor(), "field");
}
@Override

View File

@ -34,6 +34,7 @@ import com.vmware.vim25.VMwareDVSPvlanMapEntry;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class DistributedVirtualSwitchMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(DistributedVirtualSwitchMO.class);
public DistributedVirtualSwitchMO(VmwareContext context, ManagedObjectReference morDvs) {
@ -62,7 +63,7 @@ public class DistributedVirtualSwitchMO extends BaseMO {
public TaskInfo updateVMWareDVSwitchGetTask(ManagedObjectReference dvSwitchMor, VMwareDVSConfigSpec dvsSpec) throws Exception {
ManagedObjectReference task = _context.getService().reconfigureDvsTask(dvSwitchMor, dvsSpec);
TaskInfo info = (TaskInfo)(_context.getVimClient().getDynamicProperty(task, "info"));
boolean waitvalue = _context.getVimClient().waitForTask(task);
_context.getVimClient().waitForTask(task);
return info;
}

View File

@ -181,7 +181,7 @@ public class HostDatastoreSystemMO extends BaseMO {
}
public List<ManagedObjectReference> getDatastores() throws Exception {
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
return _context.getVimClient().getDynamicProperty(_mor, "datastore");
}
public DatastoreInfo getDatastoreInfo(ManagedObjectReference morDatastore) throws Exception {

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class HostFirewallSystemMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(HostFirewallSystemMO.class);
public HostFirewallSystemMO(VmwareContext context, ManagedObjectReference morFirewallSystem) {

View File

@ -91,11 +91,11 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public List<VirtualNicManagerNetConfig> getHostVirtualNicManagerNetConfig() throws Exception {
return (List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
return _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
}
public List<HostIpRouteEntry> getHostIpRouteEntries() throws Exception {
return (List<HostIpRouteEntry>)_context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
return _context.getVimClient().getDynamicProperty(_mor, "config.network.routeTableInfo.ipRoute");
}
public HostListSummaryQuickStats getHostQuickStats() throws Exception {
@ -222,7 +222,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public ManagedObjectReference[] getHostLocalDatastore() throws Exception {
List<ManagedObjectReference> datastores = (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "datastore");
List<ManagedObjectReference> datastores = _context.getVimClient().getDynamicProperty(_mor, "datastore");
List<ManagedObjectReference> l = new ArrayList<ManagedObjectReference>();
if (datastores != null) {
for (ManagedObjectReference mor : datastores) {
@ -235,7 +235,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public HostVirtualSwitch getHostVirtualSwitchByName(String name) throws Exception {
List<HostVirtualSwitch> switches = (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
List<HostVirtualSwitch> switches = _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
if (switches != null) {
for (HostVirtualSwitch vswitch : switches) {
@ -247,7 +247,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public List<HostVirtualSwitch> getHostVirtualSwitch() throws Exception {
return (List<HostVirtualSwitch>)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
return _context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch");
}
public AboutInfo getHostAboutInfo() throws Exception {
@ -326,7 +326,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
assert (nicType != null);
List<VirtualNicManagerNetConfig> netConfigs =
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
if (netConfigs != null) {
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
@ -364,7 +364,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public void createPortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
assert (portGroupName != null);
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
assert (hostNetMo != null);
@ -384,7 +384,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public void updatePortGroup(HostVirtualSwitch vSwitch, String portGroupName, Integer vlanId, HostNetworkSecurityPolicy secPolicy,
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
HostNetworkTrafficShapingPolicy shapingPolicy) throws Exception {
assert (portGroupName != null);
HostNetworkSystemMO hostNetMo = getHostNetworkSystemMO();
assert (hostNetMo != null);
@ -450,7 +450,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
public List<ManagedObjectReference> getVmMorsOnNetwork(String portGroupName) throws Exception {
ManagedObjectReference morNetwork = getNetworkMor(portGroupName);
if (morNetwork != null)
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(morNetwork, "vm");
return _context.getVimClient().getDynamicProperty(morNetwork, "vm");
return null;
}
@ -612,7 +612,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
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));
new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("VirtualMachine");
@ -645,7 +645,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
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));
new Gson().toJson(propertyPaths));
PropertySpec pSpec = new PropertySpec();
pSpec.setType("Datastore");
@ -710,7 +710,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 +
",datastoreName: " + datastoreName + ", diskOption: " + diskOption);
",datastoreName: " + datastoreName + ", diskOption: " + diskOption);
DatastoreMO dsMo = getHostDatastoreMO(datastoreName);
if (dsMo == null)
@ -733,16 +733,16 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
@Override
public boolean createBlankVm(String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz, boolean limitCpuUse, int memoryMB,
int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
int memoryReserveMB, 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 + ", cpuSpeedMhz: " +
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
cpuSpeedMHz + ", cpuReservedMHz: " + cpuReservedMHz + ", limitCpu: " + limitCpuUse + ", memoryMB: " + memoryMB + ", guestOS: " + guestOsIdentifier +
", datastore: " + morDs.getValue() + ", snapshotDirToParent: " + snapshotDirToParent);
boolean result =
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
guestOsIdentifier, morDs, snapshotDirToParent);
HypervisorHostHelper.createBlankVm(this, vmName, vmInternalCSName, cpuCount, cpuSpeedMHz, cpuReservedMHz, limitCpuUse, memoryMB, memoryReserveMB,
guestOsIdentifier, morDs, snapshotDirToParent);
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - createBlankVm() done");
@ -750,7 +750,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
public ManagedObjectReference getExistingDataStoreOnHost(boolean vmfsDatastore, String hostAddress, int hostPort, String path, String uuid,
HostDatastoreSystemMO hostDatastoreSystemMo) {
HostDatastoreSystemMO hostDatastoreSystemMo) {
// First retrieve the list of Datastores on the host.
List<ManagedObjectReference> morArray;
try {
@ -786,7 +786,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
HostDatastoreSystemMO hostDatastoreSystemMo = getHostDatastoreSystemMO();
ManagedObjectReference morDatastore = hostDatastoreSystemMo.findDatastore(poolUuid);
@ -796,14 +796,14 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
morDatastore = hostDatastoreSystemMo.createNfsDatastore(poolHostAddress, poolHostPort, poolPath, poolUuid);
} catch (AlreadyExistsFaultMsg 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: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
" Details: vCenter API trace - mountDatastore(). target MOR: " + _mor.getValue() + ", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress +
", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " + poolUuid);
// Retrieve the morDatastore and return it.
return (getExistingDataStoreOnHost(vmfsDatastore, poolHostAddress, 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: " + vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " +
poolUuid + ". Exception mesg: " + e.getMessage());
", vmfs: " + vmfsDatastore + ", poolHost: " + poolHostAddress + ", poolHostPort: " + poolHostPort + ", poolPath: " + poolPath + ", poolUuid: " +
poolUuid + ". Exception mesg: " + e.getMessage());
throw new Exception("Creation of NFS datastore on vCenter failed.");
}
if (morDatastore == null) {
@ -905,9 +905,9 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
VmwareHypervisorHostNetworkSummary summary = new VmwareHypervisorHostNetworkSummary();
if (this.getHostType() == VmwareHostType.ESXi) {
if (getHostType() == VmwareHostType.ESXi) {
List<VirtualNicManagerNetConfig> netConfigs =
(List<VirtualNicManagerNetConfig>)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig");
assert (netConfigs != null);
for (VirtualNicManagerNetConfig netConfig : netConfigs) {
@ -927,7 +927,7 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
}
} else {
// try with ESX path
List<HostVirtualNic> hostVNics = (List<HostVirtualNic>)_context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
List<HostVirtualNic> hostVNics = _context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic");
if (hostVNics != null) {
for (HostVirtualNic vnic : hostVNics) {

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.ManagedObjectReference;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class HostNetworkSystemMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(HostNetworkSystemMO.class);
public HostNetworkSystemMO(VmwareContext context, ManagedObjectReference morNetworkSystem) {

View File

@ -195,7 +195,7 @@ public class HypervisorHostHelper {
}
public static void createPortProfile(VmwareContext context, String ethPortProfileName, String networkName, Integer vlanId, Integer networkRateMbps,
long peakBandwidth, long burstSize, String gateway, boolean configureVServiceInNexus) throws Exception {
long peakBandwidth, long burstSize, String gateway, boolean configureVServiceInNexus) throws Exception {
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
String vsmIp = vsmCredentials.get("vsmip");
String vsmUserName = vsmCredentials.get("vsmusername");
@ -229,7 +229,7 @@ public class HypervisorHostHelper {
}
} catch (CloudRuntimeException e) {
msg =
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
"burst size = " + burstSize + ". Exception: " + e.toString();
s_logger.error(msg);
if (netconfClient != null) {
@ -274,7 +274,7 @@ public class HypervisorHostHelper {
netconfClient.addVServiceNode(vlanId.toString(), gateway);
s_logger.info("Adding port profile with vservice details configured over VLAN : " + vlanId.toString());
netconfClient.addPortProfile(networkName, PortProfileType.vethernet, BindingType.portbindingstatic, SwitchPortMode.access, vlanId.intValue(), vdc,
esp);
esp);
}
}
} catch (CloudRuntimeException e) {
@ -305,7 +305,7 @@ public class HypervisorHostHelper {
}
public static void updatePortProfile(VmwareContext context, String ethPortProfileName, String vethPortProfileName, Integer vlanId, Integer networkRateMbps,
long peakBandwidth, long burstRate) throws Exception {
long peakBandwidth, long burstRate) throws Exception {
NetconfHelper netconfClient = null;
Map<String, String> vsmCredentials = getValidatedVsmCredentials(context);
String vsmIp = vsmCredentials.get("vsmip");
@ -346,7 +346,7 @@ public class HypervisorHostHelper {
netconfClient.addPolicyMap(policyName, averageBandwidth, (int)peakBandwidth, (int)burstRate);
} catch (CloudRuntimeException e) {
msg =
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
"Failed to add policy map of " + policyName + " with parameters " + "committed rate = " + averageBandwidth + "peak bandwidth = " + peakBandwidth +
"burst size = " + burstRate + ". Exception: " + e.toString();
s_logger.error(msg);
if (netconfClient != null) {
@ -433,8 +433,8 @@ public class HypervisorHostHelper {
*/
public static Pair<ManagedObjectReference, String> prepareNetwork(String physicalNetwork, String namePrefix, HostMO hostMo, String vlanId, String secondaryvlanId,
Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, VirtualSwitchType vSwitchType, int numPorts, String gateway,
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) throws Exception {
Integer networkRateMbps, Integer networkRateMulticastMbps, long timeOutMs, VirtualSwitchType vSwitchType, int numPorts, String gateway,
boolean configureVServiceInNexus, BroadcastDomainType broadcastDomainType) throws Exception {
ManagedObjectReference morNetwork = null;
VmwareContext context = hostMo.getContext();
ManagedObjectReference dcMor = hostMo.getHyperHostDatacenter();
@ -457,7 +457,7 @@ public class HypervisorHostHelper {
* prepare networks for in this function.
*/
BroadcastDomainType[] supportedBroadcastTypes =
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
@ -664,8 +664,8 @@ public class HypervisorHostHelper {
}
private static void createPortGroup(String physicalNetwork, String networkName, Integer vid, Integer spvlanid, DatacenterMO dataCenterMo,
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported)
throws Exception {
DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy, DistributedVirtualSwitchMO dvSwitchMo, int numPorts, boolean autoExpandSupported)
throws Exception {
VmwareDistributedVirtualSwitchVlanSpec vlanSpec = null;
VmwareDistributedVirtualSwitchPvlanSpec pvlanSpec = null;
VMwareDVSPortSetting dvsPortSetting = null;
@ -784,7 +784,7 @@ public class HypervisorHostHelper {
}
public static VMwareDVSPortSetting createVmwareDVPortSettingSpec(DVSTrafficShapingPolicy shapingPolicy, DVSSecurityPolicy secPolicy,
VmwareDistributedVirtualSwitchVlanSpec vlanSpec) {
VmwareDistributedVirtualSwitchVlanSpec vlanSpec) {
VMwareDVSPortSetting dvsPortSetting = new VMwareDVSPortSetting();
dvsPortSetting.setVlan(vlanSpec);
dvsPortSetting.setSecurityPolicy(secPolicy);
@ -864,7 +864,7 @@ public class HypervisorHostHelper {
}
public static Pair<ManagedObjectReference, String> prepareNetwork(String vSwitchName, String namePrefix, HostMO hostMo, String vlanId, Integer networkRateMbps,
Integer networkRateMulticastMbps, long timeOutMs, boolean syncPeerHosts, BroadcastDomainType broadcastDomainType, String nicUuid) throws Exception {
Integer networkRateMulticastMbps, long timeOutMs, boolean syncPeerHosts, BroadcastDomainType broadcastDomainType, String nicUuid) throws Exception {
HostVirtualSwitch vSwitch;
if (vSwitchName == null) {
@ -887,7 +887,7 @@ public class HypervisorHostHelper {
* prepare networks for in this function.
*/
BroadcastDomainType[] supportedBroadcastTypes =
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
new BroadcastDomainType[] {BroadcastDomainType.Lswitch, BroadcastDomainType.LinkLocal, BroadcastDomainType.Native, BroadcastDomainType.Pvlan,
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan};
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
@ -981,7 +981,7 @@ public class HypervisorHostHelper {
try {
if (lock.lock(DEFAULT_LOCK_TIMEOUT_SECONDS)) {
try {
List<ManagedObjectReference> hosts = (List<ManagedObjectReference>)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
List<ManagedObjectReference> hosts = hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host");
if (hosts != null) {
for (ManagedObjectReference otherHost : hosts) {
if (!otherHost.getValue().equals(hostMo.getMor().getValue())) {
@ -990,7 +990,7 @@ public class HypervisorHostHelper {
if (s_logger.isDebugEnabled())
s_logger.debug("Prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
prepareNetwork(vSwitchName, namePrefix, otherHostMo, vlanId, networkRateMbps, networkRateMulticastMbps, timeOutMs, false,
broadcastDomainType, nicUuid);
broadcastDomainType, nicUuid);
} catch (Exception e) {
s_logger.warn("Unable to prepare network on other host, vlan: " + vlanId + ", host: " + otherHostMo.getHostName());
}
@ -1109,7 +1109,7 @@ public class HypervisorHostHelper {
}
public static boolean createBlankVm(VmwareHypervisorHost host, String vmName, String vmInternalCSName, int cpuCount, int cpuSpeedMHz, int cpuReservedMHz,
boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
boolean limitCpuUse, int memoryMB, int memoryReserveMB, String guestOsIdentifier, ManagedObjectReference morDs, boolean snapshotDirToParent) throws Exception {
if (s_logger.isInfoEnabled())
s_logger.info("Create blank VM. cpuCount: " + cpuCount + ", cpuSpeed(MHz): " + cpuSpeedMHz + ", mem(Mb): " + memoryMB);
@ -1274,7 +1274,7 @@ public class HypervisorHostHelper {
}
public static void importVmFromOVF(VmwareHypervisorHost host, String ovfFilePath, String vmName, DatastoreMO dsMo, String diskOption, ManagedObjectReference morRp,
ManagedObjectReference morHost) throws Exception {
ManagedObjectReference morHost) throws Exception {
assert (morRp != null);
@ -1289,7 +1289,7 @@ 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);
context.getService().createImportSpec(context.getServiceContent().getOvfManager(), ovfDescriptor, morRp, dsMo.getMor(), importSpecParams);
if (ovfImportResult == null) {
String msg = "createImportSpec() failed. ovfFilePath: " + ovfFilePath + ", vmName: " + vmName + ", diskOption: " + diskOption;

View File

@ -30,10 +30,8 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
public class LicenseAssignmentManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(LicenseAssignmentManagerMO.class);
private static final String LICENSE_INFO_PRODUCT_VERSION = "ProductVersion";
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";
public LicenseAssignmentManagerMO(VmwareContext context, ManagedObjectReference mor) {

View File

@ -24,6 +24,7 @@ import com.cloud.hypervisor.vmware.util.VmwareContext;
public class LicenseManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(LicenseManagerMO.class);
private ManagedObjectReference _licenseAssignmentManager = null;

View File

@ -36,6 +36,6 @@ public class NetworkMO extends BaseMO {
}
public List<ManagedObjectReference> getVMsOnNetwork() throws Exception {
return (List<ManagedObjectReference>)_context.getVimClient().getDynamicProperty(_mor, "vm");
return _context.getVimClient().getDynamicProperty(_mor, "vm");
}
}

View File

@ -76,7 +76,7 @@ public class PerfManagerMO extends BaseMO {
public List<PerfMetricId> queryAvailablePerfMetric(ManagedObjectReference morEntity, Calendar beginTime, Calendar endTime, Integer intervalId) throws Exception {
return _context.getService().queryAvailablePerfMetric(_mor, morEntity, calendarToXMLGregorianCalendar(beginTime), calendarToXMLGregorianCalendar(endTime),
intervalId);
intervalId);
}
public PerfCompositeMetric queryPerfComposite(PerfQuerySpec spec) throws Exception {
@ -114,10 +114,10 @@ public class PerfManagerMO extends BaseMO {
}
public List<PerfCounterInfo> getCounterInfo() throws Exception {
return (List<PerfCounterInfo>)_context.getVimClient().getDynamicProperty(_mor, "perfCounter");
return _context.getVimClient().getDynamicProperty(_mor, "perfCounter");
}
public List<PerfInterval> getIntervalInfo() throws Exception {
return (List<PerfInterval>)_context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
return _context.getVimClient().getDynamicProperty(_mor, "historicalInterval");
}
}

View File

@ -25,6 +25,7 @@ import com.vmware.vim25.VirtualDiskSpec;
import com.cloud.hypervisor.vmware.util.VmwareContext;
public class VirtualDiskManagerMO extends BaseMO {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(VirtualDiskManagerMO.class);
public VirtualDiskManagerMO(VmwareContext context) {
@ -40,7 +41,7 @@ public class VirtualDiskManagerMO extends BaseMO {
}
public void copyVirtualDisk(String srcName, ManagedObjectReference morSrcDc, String destName, ManagedObjectReference morDestDc, VirtualDiskSpec diskSpec,
boolean force) throws Exception {
boolean force) throws Exception {
ManagedObjectReference morTask = _context.getService().copyVirtualDiskTask(_mor, srcName, morSrcDc, destName, morDestDc, diskSpec, force);

View File

@ -489,7 +489,7 @@ public class VirtualMachineMO extends BaseMO {
}
public String
getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List<Pair<ManagedObjectReference, String>> datastoreMounts, String snapshotDiskFile)
getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List<Pair<ManagedObjectReference, String>> datastoreMounts, String snapshotDiskFile)
throws Exception {
// if file path start with "/", need to search all datastore mounts on the host in order
@ -597,7 +597,7 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean createFullClone(String cloneName, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool, ManagedObjectReference morDs)
throws Exception {
throws Exception {
VirtualMachineCloneSpec cloneSpec = new VirtualMachineCloneSpec();
VirtualMachineRelocateSpec relocSpec = new VirtualMachineRelocateSpec();
@ -621,7 +621,7 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean createLinkedClone(String cloneName, ManagedObjectReference morBaseSnapshot, ManagedObjectReference morFolder, ManagedObjectReference morResourcePool,
ManagedObjectReference morDs) throws Exception {
ManagedObjectReference morDs) throws Exception {
assert (morBaseSnapshot != null);
assert (morFolder != null);
@ -772,8 +772,8 @@ public class VirtualMachineMO extends BaseMO {
}
NetworkDetails details =
new NetworkDetails(name, oc.getObj(), (morVms != null ? morVms.getManagedObjectReference().toArray(
new ManagedObjectReference[morVms.getManagedObjectReference().size()]) : null), gcTagValue);
new NetworkDetails(name, oc.getObj(), (morVms != null ? morVms.getManagedObjectReference().toArray(
new ManagedObjectReference[morVms.getManagedObjectReference().size()]) : null), gcTagValue);
networks.add(details);
}
@ -811,13 +811,13 @@ public class VirtualMachineMO extends BaseMO {
String vmxPathTokens[] = vmxFilePath.split("\\[|\\]|/");
StringBuffer sb = new StringBuffer("https://" + _context.getServerAddress() + "/folder/");
sb.append(URLEncoder.encode(vmxPathTokens[2].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[2].trim(), "UTF-8"));
sb.append("/");
sb.append(URLEncoder.encode(vmxPathTokens[3].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[3].trim(), "UTF-8"));
sb.append("?dcPath=");
sb.append(URLEncoder.encode(dcInfo.second()));
sb.append(URLEncoder.encode(dcInfo.second(), "UTF-8"));
sb.append("&dsName=");
sb.append(URLEncoder.encode(vmxPathTokens[1].trim()));
sb.append(URLEncoder.encode(vmxPathTokens[1].trim(), "UTF-8"));
return sb.toString();
}
@ -906,12 +906,12 @@ public class VirtualMachineMO extends BaseMO {
// vmdkDatastorePath: [datastore name] vmdkFilePath
public void createDisk(String vmdkDatastorePath, VirtualDiskType diskType, VirtualDiskMode diskMode, String rdmDeviceName, int sizeInMb,
ManagedObjectReference morDs, int controllerKey) throws Exception {
ManagedObjectReference morDs, int controllerKey) throws Exception {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - createDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", sizeInMb: " + sizeInMb +
", diskType: " + diskType + ", diskMode: " + diskMode + ", rdmDeviceName: " + rdmDeviceName + ", datastore: " + morDs.getValue() + ", controllerKey: " +
controllerKey);
", diskType: " + diskType + ", diskMode: " + diskMode + ", rdmDeviceName: " + rdmDeviceName + ", datastore: " + morDs.getValue() + ", controllerKey: " +
controllerKey);
assert (vmdkDatastorePath != null);
assert (morDs != null);
@ -995,7 +995,7 @@ public class VirtualMachineMO extends BaseMO {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain) +
", datastore: " + morDs.getValue());
", datastore: " + morDs.getValue());
VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, getScsiDeviceControllerKey(), vmdkDatastorePathChain, morDs, -1, 1);
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
@ -1055,7 +1055,7 @@ public class VirtualMachineMO extends BaseMO {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - detachDisk(). target MOR: " + _mor.getValue() + ", vmdkDatastorePath: " + vmdkDatastorePath + ", deleteBacking: " +
deleteBackingFile);
deleteBackingFile);
// Note: if VM has been taken snapshot, original backing file will be renamed, therefore, when we try to find the matching
// VirtualDisk, we only perform prefix matching
@ -1152,7 +1152,7 @@ public class VirtualMachineMO extends BaseMO {
if (s_logger.isTraceEnabled())
s_logger.trace("vCenter API trace - attachIso(). target MOR: " + _mor.getValue() + ", isoDatastorePath: " + isoDatastorePath + ", datastore: " +
morDs.getValue() + ", connect: " + connect + ", connectAtBoot: " + connectAtBoot);
morDs.getValue() + ", connect: " + connect + ", connectAtBoot: " + connectAtBoot);
assert (isoDatastorePath != null);
assert (morDs != null);
@ -1260,7 +1260,7 @@ public class VirtualMachineMO extends BaseMO {
}
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
", for safe operation we will automatically decline it");
", for safe operation we will automatically decline it");
vmMo.answerVM(question.getId(), "1");
break;
}
@ -1277,7 +1277,7 @@ public class VirtualMachineMO extends BaseMO {
msgText = tokens[1];
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
vmMo.answerVM(question.getId(), "1");
}
}
@ -1609,7 +1609,7 @@ public class VirtualMachineMO extends BaseMO {
// return the disk chain (VMDK datastore paths) for cloned snapshot
public Pair<VirtualMachineMO, String[]> cloneFromCurrentSnapshot(String clonedVmName, int cpuSpeedMHz, int memoryMb, String diskDevice, ManagedObjectReference morDs)
throws Exception {
throws Exception {
assert (morDs != null);
String[] disks = getCurrentSnapshotDiskChainDatastorePaths(diskDevice);
VirtualMachineMO clonedVm = cloneFromDiskChain(clonedVmName, cpuSpeedMHz, memoryMb, disks, morDs);
@ -1796,7 +1796,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getScsiDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1811,7 +1811,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getScsiDeviceControllerKeyNoException() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1847,7 +1847,7 @@ 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 {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
s_logger.info("Look for disk device info from volume : " + vmdkDatastorePath);
DatastoreFile dsSrcFile = new DatastoreFile(vmdkDatastorePath);
@ -1893,7 +1893,7 @@ public class VirtualMachineMO extends BaseMO {
}
public String getDiskCurrentTopBackingFileInChain(String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -1915,7 +1915,7 @@ public class VirtualMachineMO extends BaseMO {
}
public VirtualDisk getDiskDeviceByDeviceBusName(String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -1933,7 +1933,7 @@ public class VirtualMachineMO extends BaseMO {
public VirtualMachineDiskInfoBuilder getDiskInfoBuilder() throws Exception {
VirtualMachineDiskInfoBuilder builder = new VirtualMachineDiskInfoBuilder();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2049,7 +2049,7 @@ public class VirtualMachineMO extends BaseMO {
public List<VirtualDisk> getVirtualDisks() throws Exception {
List<VirtualDisk> virtualDisks = new ArrayList<VirtualDisk>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -2061,7 +2061,7 @@ public class VirtualMachineMO extends BaseMO {
}
public List<String> detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
List<String> detachedDiskFiles = new ArrayList<String>();
@ -2105,12 +2105,12 @@ public class VirtualMachineMO extends BaseMO {
}
public List<VirtualDevice> getAllDeviceList() throws Exception {
return (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
return _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
}
public VirtualDisk[] getAllDiskDevice() throws Exception {
List<VirtualDisk> deviceList = new ArrayList<VirtualDisk>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualDisk) {
@ -2163,7 +2163,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int tryGetIDEDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2177,7 +2177,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getIDEDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2197,7 +2197,7 @@ public class VirtualMachineMO extends BaseMO {
}
public VirtualDevice getIsoDevice() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
if (device instanceof VirtualCdrom) {
@ -2209,7 +2209,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getPCIDeviceControllerKey() throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null && devices.size() > 0) {
for (VirtualDevice device : devices) {
@ -2229,7 +2229,7 @@ public class VirtualMachineMO extends BaseMO {
}
public int getNextDeviceNumber(int controllerKey) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
int deviceNumber = -1;
if (devices != null && devices.size() > 0) {
@ -2245,7 +2245,7 @@ public class VirtualMachineMO extends BaseMO {
}
private List<VirtualDevice> getNicDevices(boolean sorted) throws Exception {
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> nics = new ArrayList<VirtualDevice>();
if (devices != null) {
@ -2325,7 +2325,7 @@ public class VirtualMachineMO extends BaseMO {
List<VirtualDevice> returnList = new ArrayList<VirtualDevice>();
List<VirtualDevice> devices = (List<VirtualDevice>)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
List<VirtualDevice> devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device");
if (devices != null) {
for (VirtualDevice device : devices) {
@ -2346,7 +2346,6 @@ public class VirtualMachineMO extends BaseMO {
}
public boolean unmountToolsInstaller() throws Exception {
int i = 1;
// Monitor VM questions
final Boolean[] flags = {false};
final VirtualMachineMO vmMo = this;
@ -2376,7 +2375,7 @@ public class VirtualMachineMO extends BaseMO {
}
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msg.getId())) {
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + msg.getId() +
", for safe operation we will automatically decline it");
", for safe operation we will automatically decline it");
vmMo.answerVM(question.getId(), "1");
break;
}
@ -2393,7 +2392,7 @@ public class VirtualMachineMO extends BaseMO {
msgText = tokens[1];
if ("msg.cdromdisconnect.locked".equalsIgnoreCase(msgId)) {
s_logger.info("Found that VM has a pending question that we need to answer programmatically, question id: " + question.getId() +
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
". Message id : " + msgId + ". Message text : " + msgText + ", for safe operation we will automatically decline it.");
vmMo.answerVM(question.getId(), "1");
}
}

View File

@ -27,8 +27,8 @@ import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.WebServiceException;
import javax.xml.ws.handler.MessageContext;
import org.apache.log4j.Logger;
@ -144,6 +144,7 @@ public class VmwareClient {
ServiceContent serviceContent = vimPort.retrieveServiceContent(svcInstRef);
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
@SuppressWarnings("unchecked")
Map<String, List<String>> headers = (Map<String, List<String>>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> cookies = headers.get("Set-cookie");
String cookieValue = cookies.get(0);
@ -256,17 +257,18 @@ public class VmwareClient {
* @throws Exception
* in case of error.
*/
public Object getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
@SuppressWarnings("unchecked")
public <T> T getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception {
List<String> props = new ArrayList<String>();
props.add(propertyName);
List<ObjectContent> objContent = retrieveMoRefProperties(mor, props);
Object propertyValue = null;
T propertyValue = null;
if (objContent != null && objContent.size() > 0) {
List<DynamicProperty> dynamicProperty = objContent.get(0).getPropSet();
if (dynamicProperty != null && dynamicProperty.size() > 0) {
DynamicProperty dp = dynamicProperty.get(0);
propertyValue = dp.getVal();
propertyValue = (T)dp.getVal();
/*
* If object is ArrayOfXXX object, then get the XXX[] by
* invoking getXXX() on the object.
@ -274,13 +276,13 @@ public class VmwareClient {
* ArrayOfManagedObjectReference.getManagedObjectReference()
* returns ManagedObjectReference[] array.
*/
Class dpCls = propertyValue.getClass();
Class<? extends Object> dpCls = propertyValue.getClass();
String dynamicPropertyName = dpCls.getName();
if (dynamicPropertyName.indexOf("ArrayOf") != -1) {
String methodName = "get" + dynamicPropertyName.substring(dynamicPropertyName.indexOf("ArrayOf") + "ArrayOf".length(), dynamicPropertyName.length());
Method getMorMethod = dpCls.getDeclaredMethod(methodName, null);
propertyValue = getMorMethod.invoke(propertyValue, (Object[])null);
Method getMorMethod = dpCls.getDeclaredMethod(methodName, (Class<?>)null);
propertyValue = (T)getMorMethod.invoke(propertyValue, (Object[])null);
}
}
}
@ -359,7 +361,7 @@ public class VmwareClient {
* @throws InvalidCollectorVersionFaultMsg
*/
private Object[] waitForValues(ManagedObjectReference objmor, String[] filterProps, String[] endWaitProps, Object[][] expectedVals) throws InvalidPropertyFaultMsg,
RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
RuntimeFaultFaultMsg, InvalidCollectorVersionFaultMsg {
// version string is initially null
String version = "";
Object[] endVals = new Object[endWaitProps.length];

View File

@ -26,6 +26,7 @@ import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
@ -375,7 +376,7 @@ public class VmwareContext {
}
}
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate progressUpdater) throws Exception {
public void uploadVmdkFile(String httpMethod, String urlString, String localFileName, long totalBytesUpdated, ActionDelegate<Long> progressUpdater) throws Exception {
HttpURLConnection conn = getRawHTTPConnection(urlString);
@ -418,7 +419,7 @@ public class VmwareContext {
}
}
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate progressUpdater) throws Exception {
public long downloadVmdkFile(String urlString, String localFileName, long totalBytesDownloaded, ActionDelegate<Long> progressUpdater) throws Exception {
HttpURLConnection conn = getRawHTTPConnection(urlString);
String cookie = _vimClient.getServiceCookie();
@ -547,7 +548,7 @@ public class VmwareContext {
</table>
</body>
</html>
*/
*/
public String[] listDatastoreDirContent(String urlString) throws Exception {
List<String> fileList = new ArrayList<String>();
String content = new String(getResourceContent(urlString));
@ -583,8 +584,12 @@ public class VmwareContext {
sb.append(_serverAddress);
sb.append("/folder/");
sb.append(relativePath);
sb.append("?dcPath=").append(URLEncoder.encode(dcName)).append("&dsName=");
sb.append(URLEncoder.encode(datastoreName));
try {
sb.append("?dcPath=").append(URLEncoder.encode(dcName, "UTF-8"));
sb.append("&dsName=").append(URLEncoder.encode(datastoreName, "UTF-8"));
} catch (UnsupportedEncodingException e) {
s_logger.error("Unable to encode URL. dcPath : " + dcName + ", dsName :" + datastoreName, e);
}
return sb.toString();
}

View File

@ -134,41 +134,6 @@ public class VmwareContextPool {
};
}
private void getIdleCheckContexts(List<VmwareContext> l, int batchSize) {
synchronized (this) {
for (Map.Entry<String, List<VmwareContext>> entry : _pool.entrySet()) {
if (entry.getValue() != null) {
int count = 0;
while (entry.getValue().size() > 0 && count < batchSize) {
VmwareContext context = entry.getValue().remove(0);
context.setPoolInfo(this, entry.getKey());
l.add(context);
count++;
}
}
}
}
}
private void doIdleCheck() {
List<VmwareContext> l = new ArrayList<VmwareContext>();
int batchSize = (int)(_idleCheckIntervalMs / 1000); // calculate batch size at 1 request/sec rate
getIdleCheckContexts(l, batchSize);
for (VmwareContext context : l) {
try {
context.idleCheck();
if (s_logger.isTraceEnabled())
s_logger.trace("Recyle context after idle check");
returnContext(context);
} catch (Throwable e) {
s_logger.warn("Exception caught during VmwareContext idle check, close and discard the context", e);
context.close();
}
}
}
private void getKeepAliveCheckContexts(List<VmwareContext> l, int batchSize) {
synchronized (this) {
int size = Math.min(_outstandingRegistry.size(), batchSize);

View File

@ -71,6 +71,7 @@ import com.cloud.utils.Ternary;
import com.cloud.utils.exception.ExceptionUtil;
public class VmwareHelper {
@SuppressWarnings("unused")
private static final Logger s_logger = Logger.getLogger(VmwareHelper.class);
public static boolean isReservedScsiDeviceNumber(int deviceNumber) {
@ -78,29 +79,29 @@ public class VmwareHelper {
}
public static VirtualDevice prepareNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String portGroupName,
String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
VirtualEthernetCard nic;
switch (deviceType) {
case E1000:
nic = new VirtualE1000();
break;
case E1000:
nic = new VirtualE1000();
break;
case PCNet32:
nic = new VirtualPCNet32();
break;
case PCNet32:
nic = new VirtualPCNet32();
break;
case Vmxnet2:
nic = new VirtualVmxnet2();
break;
case Vmxnet2:
nic = new VirtualVmxnet2();
break;
case Vmxnet3:
nic = new VirtualVmxnet3();
break;
case Vmxnet3:
nic = new VirtualVmxnet3();
break;
default:
assert (false);
nic = new VirtualE1000();
default:
assert (false);
nic = new VirtualE1000();
}
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
@ -121,29 +122,29 @@ public class VmwareHelper {
}
public static VirtualDevice prepareDvNicDevice(VirtualMachineMO vmMo, ManagedObjectReference morNetwork, VirtualEthernetCardType deviceType, String dvPortGroupName,
String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
String dvSwitchUuid, String macAddress, int deviceNumber, int contextNumber, boolean conntected, boolean connectOnStart) throws Exception {
VirtualEthernetCard nic;
switch (deviceType) {
case E1000:
nic = new VirtualE1000();
break;
case E1000:
nic = new VirtualE1000();
break;
case PCNet32:
nic = new VirtualPCNet32();
break;
case PCNet32:
nic = new VirtualPCNet32();
break;
case Vmxnet2:
nic = new VirtualVmxnet2();
break;
case Vmxnet2:
nic = new VirtualVmxnet2();
break;
case Vmxnet3:
nic = new VirtualVmxnet3();
break;
case Vmxnet3:
nic = new VirtualVmxnet3();
break;
default:
assert (false);
nic = new VirtualE1000();
default:
assert (false);
nic = new VirtualE1000();
}
final VirtualEthernetCardDistributedVirtualPortBackingInfo dvPortBacking = new VirtualEthernetCardDistributedVirtualPortBackingInfo();
@ -170,7 +171,7 @@ public class VmwareHelper {
// vmdkDatastorePath: [datastore name] vmdkFilePath
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
int deviceNumber, int contextNumber) throws Exception {
int deviceNumber, int contextNumber) throws Exception {
VirtualDisk disk = new VirtualDisk();
@ -206,7 +207,7 @@ public class VmwareHelper {
// vmdkDatastorePath: [datastore name] vmdkFilePath, create delta disk based on disk from template
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs,
VirtualDisk templateDisk, int deviceNumber, int contextNumber) throws Exception {
VirtualDisk templateDisk, int deviceNumber, int contextNumber) throws Exception {
assert (templateDisk != null);
VirtualDeviceBackingInfo parentBacking = templateDisk.getBacking();
@ -277,7 +278,7 @@ public class VmwareHelper {
// vmdkDatastorePath: [datastore name] vmdkFilePath
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, VirtualDisk device, int controllerKey, String vmdkDatastorePathChain[],
ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception {
assert (vmdkDatastorePathChain != null);
assert (vmdkDatastorePathChain.length >= 1);
@ -325,8 +326,9 @@ public class VmwareHelper {
return disk;
}
@SuppressWarnings("unchecked")
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain,
int deviceNumber, int contextNumber) throws Exception {
int deviceNumber, int contextNumber) throws Exception {
assert (vmdkDatastorePathChain != null);
assert (vmdkDatastorePathChain.length >= 1);
@ -385,6 +387,7 @@ public class VmwareHelper {
backingInfo.setParent(parentBacking);
}
@SuppressWarnings("unchecked")
private static void setParentBackingInfo(VirtualDiskFlatVer2BackingInfo backingInfo, Pair<String, ManagedObjectReference>[] parentDatastorePathList) {
VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo();
@ -403,7 +406,7 @@ public class VmwareHelper {
}
public static Pair<VirtualDevice, Boolean> prepareIsoDevice(VirtualMachineMO vmMo, String isoDatastorePath, ManagedObjectReference morDs, boolean connect,
boolean connectAtBoot, int deviceNumber, int contextNumber) throws Exception {
boolean connectAtBoot, int deviceNumber, int contextNumber) throws Exception {
boolean newCdRom = false;
VirtualCdrom cdRom = (VirtualCdrom)vmMo.getIsoDevice();
@ -549,7 +552,7 @@ public class VmwareHelper {
}
public static void setVmScaleUpConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
boolean limitCpuUse) {
boolean limitCpuUse) {
// VM config for scaling up
vmConfig.setMemoryMB((long)memoryMB);
@ -573,7 +576,7 @@ public class VmwareHelper {
}
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB,
String guestOsIdentifier, boolean limitCpuUse) {
String guestOsIdentifier, boolean limitCpuUse) {
// VM config basics
vmConfig.setMemoryMB((long)memoryMB);
@ -640,10 +643,10 @@ public class VmwareHelper {
//TODO: in vim 5.1, exceptions do not have a base exception class, MethodFault becomes a FaultInfo that we can only get
// from individual exception through getFaultInfo, so we have to use reflection here to get MethodFault information.
try {
Class cls = e.getClass();
Method mth = cls.getDeclaredMethod("getFaultInfo", null);
Class<? extends Throwable> cls = e.getClass();
Method mth = cls.getDeclaredMethod("getFaultInfo", (Class<?>)null);
if (mth != null) {
Object fault = mth.invoke(e, null);
Object fault = mth.invoke(e, (Object[])null);
if (fault instanceof MethodFault) {
final StringWriter writer = new StringWriter();
writer.append("Exception: " + fault.getClass().getName() + "\n");