Search in sources :

Example 1 with StoragePoolType

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);
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Example 2 with StoragePoolType

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);
    }
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) StrategyPriority(org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) Test(org.junit.Test)

Example 3 with StoragePoolType

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());
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) PhysicalDiskFormat(org.apache.cloudstack.utils.qemu.QemuImg.PhysicalDiskFormat)

Example 4 with StoragePoolType

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);
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) Tsm(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.Tsm) PrimaryDataStoreParameters(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreParameters) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) Map(java.util.Map)

Example 5 with StoragePoolType

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);
        }
    }
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

StoragePoolType (com.cloud.storage.Storage.StoragePoolType)27 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)13 Test (org.junit.Test)10 URISyntaxException (java.net.URISyntaxException)6 URI (java.net.URI)5 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)5 LibvirtException (org.libvirt.LibvirtException)5 StoragePool (org.libvirt.StoragePool)5 Map (java.util.Map)4 Connect (org.libvirt.Connect)4 HostVO (com.cloud.host.HostVO)3 HashSet (java.util.HashSet)3 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 LibvirtStoragePoolDef (com.cloud.hypervisor.kvm.resource.LibvirtStoragePoolDef)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 LinkedList (java.util.LinkedList)2 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)2 PrimaryDataStoreParameters (org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreParameters)2 StrategyPriority (org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority)2 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)2