mirror of https://github.com/apache/cloudstack.git
storage: Fix hypervisor type cast to string (#4516)
This PR addresses an error that appears when you try to add a new host. I don't even understand why there was a cast to String in the first place. I will assume some classes send HypervisorType and some send a string (empty or otherwise). Shouldn't this be addressed to use the same type everywhere? With this fix adding a new xenserver host works fine. Co-authored-by: dahn <daan.hoogland@gmail.com>
This commit is contained in:
parent
2aa7fac9ac
commit
fdb2ee3165
|
|
@ -276,6 +276,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
|
|||
params.put("path", uri.getPath());
|
||||
params.put("protocol", StoragePoolType.NetworkFilesystem);
|
||||
params.put("dcId", dcId.toString());
|
||||
params.put("hypervisorType", HypervisorType.None);
|
||||
params.put("clusterId", clusterId.toString());
|
||||
params.put("name", this.primaryName);
|
||||
params.put("port", "1");
|
||||
|
|
@ -318,6 +319,7 @@ public class VolumeServiceTest extends CloudStackTestNGBase {
|
|||
params.put("path", uri.getPath());
|
||||
params.put("protocol", Storage.StoragePoolType.NetworkFilesystem);
|
||||
params.put("dcId", dcId.toString());
|
||||
params.put("hypervisorType", HypervisorType.None);
|
||||
params.put("clusterId", clusterId.toString());
|
||||
params.put("name", this.primaryName);
|
||||
params.put("port", "1");
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
|
|||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
|
@ -132,7 +131,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
|||
Long zoneId = (Long)dsInfos.get("zoneId");
|
||||
String url = (String)dsInfos.get("url");
|
||||
String providerName = (String)dsInfos.get("providerName");
|
||||
String hypervisorType = (String)dsInfos.get("hypervisorType");
|
||||
HypervisorType hypervisorType = (HypervisorType)dsInfos.get("hypervisorType");
|
||||
if (clusterId != null && podId == null) {
|
||||
throw new InvalidParameterValueException("Cluster id requires pod id");
|
||||
}
|
||||
|
|
@ -250,7 +249,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
|||
parameters.setPath(hostPath.replaceFirst("/", ""));
|
||||
parameters.setUserInfo(userInfo);
|
||||
} else if (scheme.equalsIgnoreCase("PreSetup")) {
|
||||
if (StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware)) {
|
||||
if (HypervisorType.VMware.equals(hypervisorType)) {
|
||||
validateVcenterDetails(zoneId, podId, clusterId,storageHost);
|
||||
}
|
||||
parameters.setType(StoragePoolType.PreSetup);
|
||||
|
|
@ -258,7 +257,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
|||
parameters.setPort(0);
|
||||
parameters.setPath(hostPath);
|
||||
} else if (scheme.equalsIgnoreCase("DatastoreCluster")) {
|
||||
if (StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware)) {
|
||||
if (HypervisorType.VMware.equals(hypervisorType)) {
|
||||
validateVcenterDetails(zoneId, podId, clusterId,storageHost);
|
||||
}
|
||||
parameters.setType(StoragePoolType.DatastoreCluster);
|
||||
|
|
@ -338,7 +337,7 @@ public class CloudStackPrimaryDataStoreLifeCycleImpl implements PrimaryDataStore
|
|||
uuid = (String)existingUuid;
|
||||
} else if (scheme.equalsIgnoreCase("sharedmountpoint") || scheme.equalsIgnoreCase("clvm")) {
|
||||
uuid = UUID.randomUUID().toString();
|
||||
} else if (scheme.equalsIgnoreCase("PreSetup") && !(StringUtils.isNotBlank(hypervisorType) && HypervisorType.getType(hypervisorType).equals(HypervisorType.VMware))) {
|
||||
} else if ("PreSetup".equalsIgnoreCase(scheme) && !HypervisorType.VMware.equals(hypervisorType)) {
|
||||
uuid = hostPath.replace("/", "");
|
||||
} else {
|
||||
uuid = UUID.nameUUIDFromBytes((storageHost + hostPath).getBytes()).toString();
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
|||
params.put("zoneId", zone.getId());
|
||||
params.put("clusterId", clusterId);
|
||||
params.put("podId", podId);
|
||||
params.put("hypervisorType", hypervisorType.toString());
|
||||
params.put("hypervisorType", hypervisorType);
|
||||
params.put("url", cmd.getUrl());
|
||||
params.put("tags", cmd.getTags());
|
||||
params.put("name", cmd.getStoragePoolName());
|
||||
|
|
|
|||
Loading…
Reference in New Issue