Skip to content

Commit 532bf4b

Browse files
committed
Get rid of compiler warnings and dead code in plugin-hypervisor-vmware
1 parent b20add8 commit 532bf4b

13 files changed

Lines changed: 332 additions & 543 deletions

File tree

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/LegacyZoneVO.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@
2727
import com.cloud.utils.NumbersUtil;
2828

2929
/**
30-
* LegacyZoneVO contains id of CloudStack zone containing clusters from multiple VMware vCetners and/or VMware Datacenters.
31-
*/
30+
* LegacyZoneVO contains id of CloudStack zone containing clusters from multiple VMware vCetners and/or VMware Datacenters.
31+
*/
3232

3333
@Entity
3434
@Table(name = "legacy_zones")
3535
public class LegacyZoneVO implements LegacyZone {
3636

37+
private static final long serialVersionUID = -3979866054555152793L;
38+
3739
@Id
3840
@GeneratedValue(strategy = GenerationType.IDENTITY)
3941
@Column(name = "id")
@@ -60,7 +62,7 @@ public int hashCode() {
6062
@Override
6163
public boolean equals(Object obj) {
6264
if (obj instanceof LegacyZoneVO) {
63-
return ((LegacyZoneVO)obj).getId() == this.getId();
65+
return ((LegacyZoneVO)obj).getId() == getId();
6466
} else {
6567
return false;
6668
}
@@ -70,7 +72,7 @@ public LegacyZoneVO() {
7072
}
7173

7274
public LegacyZoneVO(long zoneId) {
73-
this.id = zoneId;
75+
id = zoneId;
7476
}
7577

7678
public LegacyZoneVO(long id, long zoneId) {

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareCleanupMaid.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// under the License.
1717
package com.cloud.hypervisor.vmware;
1818

19-
import java.util.ArrayList;
2019
import java.util.HashMap;
2120
import java.util.List;
2221
import java.util.Map;
@@ -98,16 +97,6 @@ public long getCheckPoint() {
9897
return _checkPoint;
9998
}
10099

101-
private synchronized static void addLeftOverVM(VmwareCleanupMaid cleanupMaid) {
102-
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(cleanupMaid.getVCenterServer());
103-
if (l == null) {
104-
l = new ArrayList<VmwareCleanupMaid>();
105-
s_leftoverDummyVMs.put(cleanupMaid.getVCenterServer(), l);
106-
}
107-
108-
l.add(cleanupMaid);
109-
}
110-
111100
public synchronized static void gcLeftOverVMs(VmwareContext context) {
112101
List<VmwareCleanupMaid> l = s_leftoverDummyVMs.get(context.getServerAddress());
113102
VmwareManager mgr = context.getStockObject(VmwareManager.CONTEXT_STOCK_NAME);

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterVO.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
@Table(name = "vmware_data_center")
3838
public class VmwareDatacenterVO implements VmwareDatacenter {
3939

40+
private static final long serialVersionUID = -9114941929893819232L;
41+
4042
@Id
4143
@GeneratedValue(strategy = GenerationType.IDENTITY)
4244
@Column(name = "id")
@@ -105,11 +107,11 @@ public void setGuid(String guid) {
105107
}
106108

107109
public void setVmwareDatacenterName(String name) {
108-
this.vmwareDatacenterName = name;
110+
vmwareDatacenterName = name;
109111
}
110112

111113
public void setVcenterHost(String vCenterHost) {
112-
this.vcenterHost = vCenterHost;
114+
vcenterHost = vCenterHost;
113115
}
114116

115117
public void setUser(String user) {
@@ -134,17 +136,17 @@ public int hashCode() {
134136
@Override
135137
public boolean equals(Object obj) {
136138
if (obj instanceof VmwareDatacenterVO) {
137-
return ((VmwareDatacenterVO)obj).getId() == this.getId();
139+
return ((VmwareDatacenterVO)obj).getId() == getId();
138140
} else {
139141
return false;
140142
}
141143
}
142144

143145
public VmwareDatacenterVO(String guid, String name, String vCenterHost, String user, String password) {
144-
this.uuid = UUID.randomUUID().toString();
145-
this.vmwareDatacenterName = name;
146+
uuid = UUID.randomUUID().toString();
147+
vmwareDatacenterName = name;
146148
this.guid = guid;
147-
this.vcenterHost = vCenterHost;
149+
vcenterHost = vCenterHost;
148150
this.user = user;
149151
this.password = password;
150152
}
@@ -155,7 +157,7 @@ public VmwareDatacenterVO(long id, String guid, String name, String vCenterHost,
155157
}
156158

157159
public VmwareDatacenterVO() {
158-
this.uuid = UUID.randomUUID().toString();
160+
uuid = UUID.randomUUID().toString();
159161
}
160162

161163
}

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareDatacenterZoneMapVO.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
@Table(name = "vmware_data_center_zone_map")
3333
public class VmwareDatacenterZoneMapVO implements VmwareDatacenterZoneMap {
3434

35+
private static final long serialVersionUID = -2155826205976479040L;
36+
3537
@Id
3638
@GeneratedValue(strategy = GenerationType.IDENTITY)
3739
@Column(name = "id")

plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/VmwareServerDiscoverer.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public VmwareServerDiscoverer() {
126126

127127
@Override
128128
public Map<? extends ServerResource, Map<String, String>>
129-
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
129+
find(long dcId, Long podId, Long clusterId, URI url, String username, String password, List<String> hostTags) throws DiscoveryException {
130130

131131
if (s_logger.isInfoEnabled())
132132
s_logger.info("Discover host. dc: " + dcId + ", pod: " + podId + ", cluster: " + clusterId + ", uri host: " + url.getHost());
@@ -158,7 +158,7 @@ public VmwareServerDiscoverer() {
158158
if (usernameNotProvided || passwordNotProvided) {
159159
// Retrieve credentials associated with VMware DC
160160
s_logger.info("Username and/or Password not provided while adding cluster to cloudstack zone. "
161-
+ "Hence using both username & password provided while adding VMware DC to CloudStack zone.");
161+
+ "Hence using both username & password provided while adding VMware DC to CloudStack zone.");
162162
username = vmwareDc.getUser();
163163
password = vmwareDc.getPassword();
164164
clusterDetails.put("username", username);
@@ -252,7 +252,7 @@ public VmwareServerDiscoverer() {
252252

253253
// Process traffic label information provided at zone level and cluster level
254254
publicTrafficLabelObj =
255-
getTrafficInfo(TrafficType.Public, publicTrafficLabel, defaultVirtualSwitchType, paramPublicVswitchType, paramPublicVswitchName, clusterId);
255+
getTrafficInfo(TrafficType.Public, publicTrafficLabel, defaultVirtualSwitchType, paramPublicVswitchType, paramPublicVswitchName, clusterId);
256256

257257
// Configuration Check: A physical network cannot be shared by different types of virtual switches.
258258
//
@@ -272,7 +272,7 @@ public VmwareServerDiscoverer() {
272272
if (pNetworkListGuestTraffic.contains(pNetworkPublic)) {
273273
if (publicTrafficLabelObj.getVirtualSwitchType() != guestTrafficLabelObj.getVirtualSwitchType()) {
274274
String msg =
275-
"Both public traffic and guest traffic is over same physical network " + pNetworkPublic +
275+
"Both public traffic and guest traffic is over same physical network " + pNetworkPublic +
276276
". And virtual switch type chosen for each traffic is different" +
277277
". A physical network cannot be shared by different types of virtual switches.";
278278
s_logger.error(msg);
@@ -295,7 +295,7 @@ public VmwareServerDiscoverer() {
295295
}
296296
Pair<Boolean, Long> vsmInfo = new Pair<Boolean, Long>(false, 0L);
297297
if (nexusDVS && (guestTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch) ||
298-
((zoneType == NetworkType.Advanced) && (publicTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch))) {
298+
((zoneType == NetworkType.Advanced) && (publicTrafficLabelObj.getVirtualSwitchType() == VirtualSwitchType.NexusDistributedVirtualSwitch))) {
299299
// Expect Cisco Nexus VSM details only if following 2 condition met
300300
// 1) The global config parameter vmware.use.nexus.vswitch
301301
// 2) Atleast 1 traffic type uses Nexus distributed virtual switch as backend.
@@ -335,22 +335,22 @@ public VmwareServerDiscoverer() {
335335
context.registerStockObject("vsmcredentials", vsmCredentials);
336336
}
337337
}
338-
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId, URLDecoder.decode(url.getPath()));
338+
List<ManagedObjectReference> morHosts = _vmwareMgr.addHostToPodCluster(context, dcId, podId, clusterId, URLDecoder.decode(url.getPath(), "UTF-8"));
339339
if (morHosts == null)
340340
s_logger.info("Found 0 hosts.");
341341
if (privateTrafficLabel != null)
342342
context.uregisterStockObject("privateTrafficLabel");
343343

344344
if (morHosts == null) {
345-
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath()));
345+
s_logger.error("Unable to find host or cluster based on url: " + URLDecoder.decode(url.getPath(), "UTF-8"));
346346
return null;
347347
}
348348

349349
ManagedObjectReference morCluster = null;
350350
clusterDetails = _clusterDetailsDao.findDetails(clusterId);
351351
if (clusterDetails.get("url") != null) {
352352
URI uriFromCluster = new URI(UriUtils.encodeURIComponent(clusterDetails.get("url")));
353-
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath()));
353+
morCluster = context.getHostMorByPath(URLDecoder.decode(uriFromCluster.getPath(), "UTF-8"));
354354

355355
if (morCluster == null || !morCluster.getType().equalsIgnoreCase("ClusterComputeResource")) {
356356
s_logger.warn("Cluster url does not point to a valid vSphere cluster, url: " + clusterDetails.get("url"));
@@ -491,13 +491,13 @@ private String validateCluster(URI url, VmwareDatacenterVO vmwareDc) throws Disc
491491

492492
if (!vCenterHost.equalsIgnoreCase(url.getHost())) {
493493
msg =
494-
"This cluster " + clusterName + " belongs to vCenter " + url.getHost() + ". But this zone is associated with VMware DC from vCenter " + vCenterHost +
494+
"This cluster " + clusterName + " belongs to vCenter " + url.getHost() + ". But this zone is associated with VMware DC from vCenter " + vCenterHost +
495495
". Make sure the cluster being added belongs to vCenter " + vCenterHost + " and VMware DC " + vmwareDcNameFromDb;
496496
s_logger.error(msg);
497497
throw new DiscoveryException(msg);
498498
} else if (!vmwareDcNameFromDb.equalsIgnoreCase(vmwareDcNameFromApi)) {
499499
msg =
500-
"This cluster " + clusterName + " belongs to VMware DC " + vmwareDcNameFromApi + " .But this zone is associated with VMware DC " + vmwareDcNameFromDb +
500+
"This cluster " + clusterName + " belongs to VMware DC " + vmwareDcNameFromApi + " .But this zone is associated with VMware DC " + vmwareDcNameFromDb +
501501
". Make sure the cluster being added belongs to VMware DC " + vmwareDcNameFromDb + " in vCenter " + vCenterHost;
502502
s_logger.error(msg);
503503
throw new DiscoveryException(msg);
@@ -567,8 +567,8 @@ private void createVmwareToolsIso() {
567567
if (tmplt == null) {
568568
id = _tmpltDao.getNextInSequence(Long.class, "id");
569569
VMTemplateVO template =
570-
VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
571-
null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
570+
VMTemplateVO.createPreHostIso(id, isoName, isoName, ImageFormat.ISO, true, true, TemplateType.PERHOST, null, null, true, 64, Account.ACCOUNT_ID_SYSTEM,
571+
null, "VMware Tools Installer ISO", false, 1, false, HypervisorType.VMware);
572572
_tmpltDao.persist(template);
573573
} else {
574574
id = tmplt.getId();
@@ -627,7 +627,7 @@ public boolean stop() {
627627
}
628628

629629
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, VirtualSwitchType defaultVirtualSwitchType, String vSwitchType,
630-
String vSwitchName, Long clusterId) {
630+
String vSwitchName, Long clusterId) {
631631
VmwareTrafficLabel trafficLabelObj = null;
632632
Map<String, String> clusterDetails = null;
633633
try {
@@ -664,7 +664,7 @@ private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWi
664664
}
665665

666666
private VmwareTrafficLabel getTrafficInfo(TrafficType trafficType, String zoneWideTrafficLabel, Map<String, String> clusterDetails,
667-
VirtualSwitchType defVirtualSwitchType) {
667+
VirtualSwitchType defVirtualSwitchType) {
668668
VmwareTrafficLabel trafficLabelObj = null;
669669
try {
670670
trafficLabelObj = new VmwareTrafficLabel(zoneWideTrafficLabel, trafficType, defVirtualSwitchType);

0 commit comments

Comments
 (0)