Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4973810389 for ; Wed, 22 Jan 2014 11:36:29 +0000 (UTC) Received: (qmail 28957 invoked by uid 500); 22 Jan 2014 11:36:27 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 28784 invoked by uid 500); 22 Jan 2014 11:36:26 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 28707 invoked by uid 99); 22 Jan 2014 11:36:24 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 22 Jan 2014 11:36:24 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 389F7818880; Wed, 22 Jan 2014 11:36:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hugo@apache.org To: commits@cloudstack.apache.org Date: Wed, 22 Jan 2014 11:36:24 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [01/10] git commit: updated refs/heads/master to 49124bd Updated Branches: refs/heads/master 86124138a -> 49124bdb7 Get rid of compiler warnings in vmware-base Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b20add81 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b20add81 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b20add81 Branch: refs/heads/master Commit: b20add810e5751f53946f695b6223a8016f104a5 Parents: 8612413 Author: Hugo Trippaers Authored: Wed Jan 22 09:34:46 2014 +0100 Committer: Hugo Trippaers Committed: Wed Jan 22 09:37:34 2014 +0100 ---------------------------------------------------------------------- .../cloud/hypervisor/vmware/mo/ClusterMO.java | 28 +++---- .../vmware/mo/CustomFieldsManagerMO.java | 2 +- .../vmware/mo/DistributedVirtualSwitchMO.java | 3 +- .../vmware/mo/HostDatastoreSystemMO.java | 2 +- .../vmware/mo/HostFirewallSystemMO.java | 1 + .../com/cloud/hypervisor/vmware/mo/HostMO.java | 52 ++++++------ .../vmware/mo/HostNetworkSystemMO.java | 1 + .../vmware/mo/HypervisorHostHelper.java | 36 ++++---- .../vmware/mo/LicenseAssignmentManagerMO.java | 4 +- .../hypervisor/vmware/mo/LicenseManagerMO.java | 1 + .../cloud/hypervisor/vmware/mo/NetworkMO.java | 2 +- .../hypervisor/vmware/mo/PerfManagerMO.java | 6 +- .../vmware/mo/VirtualDiskManagerMO.java | 3 +- .../hypervisor/vmware/mo/VirtualMachineMO.java | 75 +++++++++-------- .../hypervisor/vmware/util/VmwareClient.java | 18 ++-- .../hypervisor/vmware/util/VmwareContext.java | 15 ++-- .../vmware/util/VmwareContextPool.java | 35 -------- .../hypervisor/vmware/util/VmwareHelper.java | 87 ++++++++++---------- 18 files changed, 174 insertions(+), 197 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 e416cb5..49ee7c4 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/ClusterMO.java @@ -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 hosts = (List)_context.getVimClient().getDynamicProperty(_mor, "host"); + List 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 hosts = (List)_context.getVimClient().getDynamicProperty(_mor, "host"); + List 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 hosts = (List)_context.getVimClient().getDynamicProperty(_mor, "host"); + List 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 hosts = (List)_context.getVimClient().getDynamicProperty(_mor, "host"); + List hosts = _context.getVimClient().getDynamicProperty(_mor, "host"); if (hosts != null && hosts.size() > 0) { VmwareHypervisorHostNetworkSummary summary = new HostMO(_context, hosts.get(0)).getHyperHostNetworkSummary(esxServiceConsolePort); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 dbc7429..78ce9a8 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/CustomFieldsManagerMO.java @@ -51,7 +51,7 @@ public class CustomFieldsManagerMO extends BaseMO { } public List getFields() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(getMor(), "field"); + return _context.getVimClient().getDynamicProperty(getMor(), "field"); } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java index 220c5a1..9e19d65 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/DistributedVirtualSwitchMO.java @@ -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; } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 2392347..9af845b 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostDatastoreSystemMO.java @@ -181,7 +181,7 @@ public class HostDatastoreSystemMO extends BaseMO { } public List getDatastores() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "datastore"); + return _context.getVimClient().getDynamicProperty(_mor, "datastore"); } public DatastoreInfo getDatastoreInfo(ManagedObjectReference morDatastore) throws Exception { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java index 4c0a995..78e98db 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostFirewallSystemMO.java @@ -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) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 f511ce2..a32992a 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostMO.java @@ -91,11 +91,11 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost { } public List getHostVirtualNicManagerNetConfig() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig"); + return _context.getVimClient().getDynamicProperty(_mor, "config.virtualNicManagerInfo.netConfig"); } public List getHostIpRouteEntries() throws Exception { - return (List)_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 datastores = (List)_context.getVimClient().getDynamicProperty(_mor, "datastore"); + List datastores = _context.getVimClient().getDynamicProperty(_mor, "datastore"); List l = new ArrayList(); 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 switches = (List)_context.getVimClient().getDynamicProperty(_mor, "config.network.vswitch"); + List 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 getHostVirtualSwitch() throws Exception { - return (List)_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 netConfigs = - (List)_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 getVmMorsOnNetwork(String portGroupName) throws Exception { ManagedObjectReference morNetwork = getNetworkMor(portGroupName); if (morNetwork != null) - return (List)_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 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 netConfigs = - (List)_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 hostVNics = (List)_context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic"); + List hostVNics = _context.getVimClient().getDynamicProperty(_mor, "config.network.consoleVnic"); if (hostVNics != null) { for (HostVirtualNic vnic : hostVNics) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java index 806b0e2..acac689 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HostNetworkSystemMO.java @@ -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) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 d4f437e..38b68b3 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/HypervisorHostHelper.java @@ -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 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 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 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 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 hosts = (List)hostMo.getContext().getVimClient().getDynamicProperty(morParent, "host"); + List 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; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java index 0a86b97..b5e1166 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseAssignmentManagerMO.java @@ -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) { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java index 7ba046d..1096fab 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/LicenseManagerMO.java @@ -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; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 43ffa25..e2797d3 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/NetworkMO.java @@ -36,6 +36,6 @@ public class NetworkMO extends BaseMO { } public List getVMsOnNetwork() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "vm"); + return _context.getVimClient().getDynamicProperty(_mor, "vm"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 205f23a..9ce028d 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/PerfManagerMO.java @@ -76,7 +76,7 @@ public class PerfManagerMO extends BaseMO { public List 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 getCounterInfo() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "perfCounter"); + return _context.getVimClient().getDynamicProperty(_mor, "perfCounter"); } public List getIntervalInfo() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "historicalInterval"); + return _context.getVimClient().getDynamicProperty(_mor, "historicalInterval"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java index 34d593f..32f5c00 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualDiskManagerMO.java @@ -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); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 8c5f0a6..99a7425 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java @@ -489,7 +489,7 @@ public class VirtualMachineMO extends BaseMO { } public String - getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List> datastoreMounts, String snapshotDiskFile) + getSnapshotDiskFileDatastorePath(VirtualMachineFileInfo vmFileInfo, List> 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 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 getDiskDevice(String vmdkDatastorePath, boolean matchExactly) throws Exception { - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 getVirtualDisks() throws Exception { List virtualDisks = new ArrayList(); - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 detachAllDisksExcept(String vmdkBaseName, String deviceBusName) throws Exception { - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec(); List detachedDiskFiles = new ArrayList(); @@ -2105,12 +2105,12 @@ public class VirtualMachineMO extends BaseMO { } public List getAllDeviceList() throws Exception { - return (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + return _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); } public VirtualDisk[] getAllDiskDevice() throws Exception { List deviceList = new ArrayList(); - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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 getNicDevices(boolean sorted) throws Exception { - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List devices = _context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); List nics = new ArrayList(); if (devices != null) { @@ -2325,7 +2325,7 @@ public class VirtualMachineMO extends BaseMO { List returnList = new ArrayList(); - List devices = (List)_context.getVimClient().getDynamicProperty(_mor, "config.hardware.device"); + List 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"); } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/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 3c2c81d..e81665f 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareClient.java @@ -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> headers = (Map>)((BindingProvider)vimPort).getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS); List 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 getDynamicProperty(ManagedObjectReference mor, String propertyName) throws Exception { List props = new ArrayList(); props.add(propertyName); List objContent = retrieveMoRefProperties(mor, props); - Object propertyValue = null; + T propertyValue = null; if (objContent != null && objContent.size() > 0) { List 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 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]; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java index eaa205e..08456c4 100755 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContext.java @@ -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 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 progressUpdater) throws Exception { HttpURLConnection conn = getRawHTTPConnection(urlString); String cookie = _vimClient.getServiceCookie(); @@ -547,7 +548,7 @@ public class VmwareContext { - */ + */ public String[] listDatastoreDirContent(String urlString) throws Exception { List fileList = new ArrayList(); 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(); } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java index e744cbf..c97c01f 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareContextPool.java @@ -134,41 +134,6 @@ public class VmwareContextPool { }; } - private void getIdleCheckContexts(List l, int batchSize) { - synchronized (this) { - for (Map.Entry> 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 l = new ArrayList(); - 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 l, int batchSize) { synchronized (this) { int size = Math.min(_outstandingRegistry.size(), batchSize); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b20add81/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java ---------------------------------------------------------------------- diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java index c1658b0..d29e0f2 100644 --- a/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java +++ b/vmware-base/src/com/cloud/hypervisor/vmware/util/VmwareHelper.java @@ -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[] 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[] parentDatastorePathList) { VirtualDiskFlatVer2BackingInfo parentBacking = new VirtualDiskFlatVer2BackingInfo(); @@ -403,7 +406,7 @@ public class VmwareHelper { } public static Pair 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 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");