Skip to content

Commit 5e42af7

Browse files
rootalexandru-bagu
authored andcommitted
proper changes to use only enum of HypervisorType
1 parent e5b7733 commit 5e42af7

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

engine/storage/integration-test/src/test/java/org/apache/cloudstack/storage/test/VolumeServiceTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ public void testCreatePrimaryStorage() {
276276
params.put("path", uri.getPath());
277277
params.put("protocol", StoragePoolType.NetworkFilesystem);
278278
params.put("dcId", dcId.toString());
279+
params.put("hypervisorType", HypervisorType.None);
279280
params.put("clusterId", clusterId.toString());
280281
params.put("name", this.primaryName);
281282
params.put("port", "1");
@@ -318,6 +319,7 @@ public DataStore createPrimaryDataStore() {
318319
params.put("path", uri.getPath());
319320
params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
320321
params.put("dcId", dcId.toString());
322+
params.put("hypervisorType", HypervisorType.None);
321323
params.put("clusterId", clusterId.toString());
322324
params.put("name", this.primaryName);
323325
params.put("port", "1");

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/lifecycle/CloudStackPrimaryDataStoreLifeCycleImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
6565
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
6666
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
67-
import org.apache.commons.lang.StringUtils;
6867
import org.apache.log4j.Logger;
6968

7069
import javax.inject.Inject;
@@ -132,7 +131,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
132131
Long zoneId = (Long)dsInfos.get("zoneId");
133132
String url = (String)dsInfos.get("url");
134133
String providerName = (String)dsInfos.get("providerName");
135-
String hypervisorType = (String)dsInfos.get("hypervisorType");
134+
HypervisorType hypervisorType = (HypervisorType)dsInfos.get("hypervisorType");
136135
if (clusterId != null && podId == null) {
137136
throw new InvalidParameterValueException("Cluster id requires pod id");
138137
}
@@ -250,15 +249,15 @@ public DataStore initialize(Map<String, Object> dsInfos) {
250249
parameters.setPath(hostPath.replaceFirst("/", ""));
251250
parameters.setUserInfo(userInfo);
252251
} else if (scheme.equalsIgnoreCase("PreSetup")) {
253-
if (StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware)) {
252+
if (hypervisorType.equals(HypervisorType.VMware)) {
254253
validateVcenterDetails(zoneId, podId, clusterId,storageHost);
255254
}
256255
parameters.setType(StoragePoolType.PreSetup);
257256
parameters.setHost(storageHost);
258257
parameters.setPort(0);
259258
parameters.setPath(hostPath);
260259
} else if (scheme.equalsIgnoreCase("DatastoreCluster")) {
261-
if (StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware)) {
260+
if (hypervisorType.equals(HypervisorType.VMware)) {
262261
validateVcenterDetails(zoneId, podId, clusterId,storageHost);
263262
}
264263
parameters.setType(StoragePoolType.DatastoreCluster);
@@ -338,7 +337,7 @@ public DataStore initialize(Map<String, Object> dsInfos) {
338337
uuid = (String)existingUuid;
339338
} else if (scheme.equalsIgnoreCase("sharedmountpoint") || scheme.equalsIgnoreCase("clvm")) {
340339
uuid = UUID.randomUUID().toString();
341-
} else if (scheme.equalsIgnoreCase("PreSetup") && !(StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware))) {
340+
} else if (scheme.equalsIgnoreCase("PreSetup") && !hypervisorType.equals(HypervisorType.VMware)) {
342341
uuid = hostPath.replace("/", "");
343342
} else {
344343
uuid = UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString();

server/src/main/java/com/cloud/storage/StorageManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws Resource
722722
params.put("zoneId", zone.getId());
723723
params.put("clusterId", clusterId);
724724
params.put("podId", podId);
725-
params.put("hypervisorType", hypervisorType.toString());
725+
params.put("hypervisorType", hypervisorType);
726726
params.put("url", cmd.getUrl());
727727
params.put("tags", cmd.getTags());
728728
params.put("name", cmd.getStoragePoolName());

0 commit comments

Comments
 (0)