use of com.cloud.storage.Storage.StoragePoolType in project CloudStack-archive by CloudStack-extras.
the class LibvirtStorageAdaptor method getStoragePoolByUri.
@Override
public KVMStoragePool getStoragePoolByUri(String uri) {
URI storageUri = null;
try {
storageUri = new URI(uri);
} catch (URISyntaxException e) {
throw new CloudRuntimeException(e.toString());
}
String sourcePath = null;
String uuid = null;
String sourceHost = "";
StoragePoolType protocal = null;
if (storageUri.getScheme().equalsIgnoreCase("nfs")) {
sourcePath = storageUri.getPath();
sourcePath = sourcePath.replace("//", "/");
sourceHost = storageUri.getHost();
uuid = UUID.randomUUID().toString();
protocal = StoragePoolType.NetworkFilesystem;
}
return createStoragePool(uuid, sourceHost, sourcePath, protocal);
}
use of com.cloud.storage.Storage.StoragePoolType in project cloudstack by apache.
the class KvmNonManagedStorageSystemDataMotionTest method internalCanHandleTestIsManaged.
@Test
public void internalCanHandleTestIsManaged() {
StoragePoolType[] storagePoolTypeArray = StoragePoolType.values();
for (int i = 0; i < storagePoolTypeArray.length; i++) {
Map<VolumeInfo, DataStore> volumeMap = configureTestInternalCanHandle(true, storagePoolTypeArray[i]);
StrategyPriority strategyPriority = kvmNonManagedStorageDataMotionStrategy.internalCanHandle(volumeMap, null, null);
Assert.assertEquals(StrategyPriority.CANT_HANDLE, strategyPriority);
}
}
use of com.cloud.storage.Storage.StoragePoolType in project cloudstack by apache.
the class LibvirtComputingResource method getResizeScriptType.
public String getResizeScriptType(final KVMStoragePool pool, final KVMPhysicalDisk vol) {
final StoragePoolType poolType = pool.getType();
final PhysicalDiskFormat volFormat = vol.getFormat();
if (pool.getType() == StoragePoolType.CLVM && volFormat == PhysicalDiskFormat.RAW) {
return "CLVM";
} else if ((poolType == StoragePoolType.NetworkFilesystem || poolType == StoragePoolType.SharedMountPoint || poolType == StoragePoolType.Filesystem || poolType == StoragePoolType.Gluster) && volFormat == PhysicalDiskFormat.QCOW2) {
return "QCOW2";
} else if (poolType == StoragePoolType.Linstor) {
return RESIZE_NOTIFY_ONLY;
}
throw new CloudRuntimeException("Cannot determine resize type from pool type " + pool.getType());
}
use of com.cloud.storage.Storage.StoragePoolType in project cloudstack by apache.
the class ElastistorPrimaryDataStoreLifeCycle method initialize.
@Override
public DataStore initialize(Map<String, Object> dsInfos) {
String url = (String) dsInfos.get("url");
Long zoneId = (Long) dsInfos.get("zoneId");
Long podId = (Long) dsInfos.get("podId");
Long clusterId = (Long) dsInfos.get("clusterId");
String storagePoolName = (String) dsInfos.get("name");
String providerName = (String) dsInfos.get("providerName");
Long capacityBytes = (Long) dsInfos.get("capacityBytes");
Long capacityIops = (Long) dsInfos.get("capacityIops");
String tags = (String) dsInfos.get("tags");
boolean managed = (Boolean) dsInfos.get("managed");
Map<String, String> details = (Map<String, String>) dsInfos.get("details");
String domainName = details.get("domainname");
String storageIp;
int storagePort = 0;
StoragePoolType storagetype = null;
String accesspath = null;
String protocoltype = null;
String mountpoint = null;
if (!managed) {
storageIp = getStorageIp(url);
storagePort = getDefaultStoragePort(url);
storagetype = getStorageType(url);
accesspath = getAccessPath(url);
protocoltype = getProtocolType(url);
String[] mp = accesspath.split("/");
mountpoint = mp[1];
} else if (details.get("hypervisortype") == "KVM") {
storageIp = url;
storagePort = 3260;
storagetype = StoragePoolType.Iscsi;
accesspath = storageIp + ":/" + storagePoolName;
} else {
storageIp = url;
storagePort = 2049;
storagetype = StoragePoolType.NetworkFilesystem;
accesspath = storageIp + ":/" + storagePoolName;
}
/**
* if the elastistor params which are required for plugin configuration
* are not injected through spring-storage-volume-cloudbyte-context.xml,
* it can be set from details map.
*/
if (details.get("esaccountid") != null)
ElastistorUtil.setElastistorAccountId(details.get("esaccountid"));
if (details.get("esdefaultgateway") != null)
ElastistorUtil.setElastistorGateway(details.get("esdefaultgateway"));
if (details.get("estntinterface") != null)
ElastistorUtil.setElastistorInterface(details.get("estntinterface"));
if (details.get("espoolid") != null)
ElastistorUtil.setElastistorPoolId(details.get("espoolid"));
if (details.get("essubnet") != null)
ElastistorUtil.setElastistorSubnet(details.get("essubnet"));
s_logger.info("Elastistor details was set successfully.");
if (capacityBytes == null || capacityBytes <= 0) {
throw new IllegalArgumentException("'capacityBytes' must be present and greater than 0.");
}
if (capacityIops == null || capacityIops <= 0) {
throw new IllegalArgumentException("'capacityIops' must be present and greater than 0.");
}
if (domainName == null) {
domainName = "ROOT";
s_logger.debug("setting the domain to ROOT");
}
// elastistor does not allow same name and ip pools.
List<StoragePoolVO> storagePoolVO = _storagePoolDao.listAll();
for (StoragePoolVO poolVO : storagePoolVO) {
if (storagePoolName.equals(poolVO.getName())) {
throw new IllegalArgumentException("Storage pool with this name already exists in elastistor, please specify a unique name. [name:" + storagePoolName + "]");
}
if (storageIp.equals(poolVO.getHostAddress())) {
throw new IllegalArgumentException("Storage pool with this ip already exists in elastistor, please specify a unique ip. [ip:" + storageIp + "]");
}
}
PrimaryDataStoreParameters parameters = new PrimaryDataStoreParameters();
parameters.setHost(storageIp);
parameters.setPort(storagePort);
parameters.setPath(accesspath);
parameters.setType(storagetype);
parameters.setZoneId(zoneId);
parameters.setPodId(podId);
parameters.setName(storagePoolName);
parameters.setProviderName(providerName);
parameters.setManaged(managed);
parameters.setCapacityBytes(capacityBytes);
parameters.setUsedBytes(0);
parameters.setCapacityIops(capacityIops);
parameters.setHypervisorType(HypervisorType.Any);
parameters.setTags(tags);
parameters.setDetails(details);
parameters.setClusterId(clusterId);
Tsm tsm = null;
if (managed) {
// creates the TSM in elastistor
tsm = createElastistorTSM(storagePoolName, storageIp, capacityBytes, capacityIops, domainName);
} else {
// creates the TSM & Volume in elastistor
tsm = createElastistorTSM(storagePoolName, storageIp, capacityBytes, capacityIops, domainName);
parameters = createElastistorVolume(parameters, tsm, storagePoolName, capacityBytes, capacityIops, protocoltype, mountpoint);
}
// setting tsm's uuid as storagepool's uuid
parameters.setUuid(tsm.getUuid());
return _dataStoreHelper.createPrimaryDataStore(parameters);
}
use of com.cloud.storage.Storage.StoragePoolType in project cloudstack by apache.
the class StorageSystemDataMotionStrategyTest method validateSupportStoragePoolTypeDefaultValues.
@Test
public void validateSupportStoragePoolTypeDefaultValues() {
Set<StoragePoolType> supportedTypes = new HashSet<>();
supportedTypes.add(StoragePoolType.NetworkFilesystem);
supportedTypes.add(StoragePoolType.SharedMountPoint);
for (StoragePoolType poolType : StoragePoolType.values()) {
boolean isSupported = strategy.supportStoragePoolType(poolType);
if (supportedTypes.contains(poolType)) {
assertTrue(isSupported);
} else {
assertFalse(isSupported);
}
}
}
Aggregations