Search in sources :

Example 6 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIORestClientTest method testQueryAllStoragePools.

@Test
public void testQueryAllStoragePools() {
    try {
        List<ScaleIOStoragePool> result = restClient.queryAllStoragePools();
        for (ScaleIOStoragePool pool : result) {
            String poolId = pool.getId();
            String poolProtectionDomainId = pool.getProtectionDomainId();
            String poolName = pool.getName();
            System.out.printf("Pool id : %s  name : %s  Protection Domain: %s %n", poolId, poolName, poolProtectionDomainId);
        }
    } catch (Exception e) {
        log.error("Exception: ", e);
        Assert.fail();
    }
}
Also used : ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) Test(org.junit.Test)

Example 7 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIOCommunicationInterface method discover.

@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
    StorageSystem.CompatibilityStatus compatibilityStatus = StorageSystem.CompatibilityStatus.COMPATIBLE;
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    _locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
    log.info("Starting discovery of ScaleIO StorageProvider. IP={} StorageSystem {}", accessProfile.getIpAddress(), storageSystem.getNativeGuid());
    String statusMsg = "";
    try {
        ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(_dbClient).getClientHandle(storageSystem);
        if (scaleIOHandle != null) {
            ScaleIOSystem sioSystem = scaleIOHandle.getSystem();
            List<ScaleIOProtectionDomain> protectionDomains = scaleIOHandle.getProtectionDomains();
            List<ScaleIOSDC> allSDCs = scaleIOHandle.queryAllSDC();
            List<ScaleIOSDS> allSDSs = scaleIOHandle.queryAllSDS();
            List<ScaleIOScsiInitiator> allSCSIInitiators = scaleIOHandle.queryAllSCSIInitiators();
            List<StoragePort> ports = new ArrayList<>();
            List<StoragePool> newPools = new ArrayList<StoragePool>();
            List<StoragePool> updatePools = new ArrayList<StoragePool>();
            List<StoragePool> allPools = new ArrayList<StoragePool>();
            String scaleIOType = StorageSystem.Type.scaleio.name();
            String installationId = sioSystem.getInstallId();
            String version = sioSystem.getVersion().replaceAll("_", ".");
            String minimumSupported = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.scaleio);
            compatibilityStatus = (VersionChecker.verifyVersionDetails(minimumSupported, version) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE : StorageSystem.CompatibilityStatus.COMPATIBLE;
            storageSystem.setFirmwareVersion(version);
            storageSystem.setCompatibilityStatus(compatibilityStatus.name());
            storageSystem.setReachableStatus(true);
            storageSystem.setLabel(storageSystem.getNativeGuid());
            for (ScaleIOProtectionDomain protectionDomain : protectionDomains) {
                String domainName = protectionDomain.getName();
                String id = String.format("%s+%s", installationId, domainName);
                String storageSystemNativeGUID = generateNativeGuid(scaleIOType, id);
                if (!storageSystemNativeGUID.equals(storageSystem.getNativeGuid())) {
                    // This is not the ProtectionDomain that we're looking for
                    continue;
                }
                String protectionDomainId = protectionDomain.getId();
                storageSystem.setSerialNumber(protectionDomainId);
                Network network = createNetwork(installationId);
                List<ScaleIOSDS> sdsList = new ArrayList<ScaleIOSDS>();
                for (ScaleIOSDS sds : allSDSs) {
                    String pdId = sds.getProtectionDomainId();
                    if (pdId.equals(protectionDomainId)) {
                        sdsList.add(sds);
                    }
                }
                List<StoragePort> thesePorts = createStoragePorts(storageSystem, compatibilityStatus.name(), network, sdsList, domainName);
                ports.addAll(thesePorts);
                createHost(network, allSDCs);
                boolean hasSCSIInitiators = createSCSIInitiatorsAndStoragePorts(storageSystem, domainName, compatibilityStatus, installationId, allSCSIInitiators, allSDCs, ports);
                List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(ports, _dbClient, storageSystem.getId());
                if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
                    ports.addAll(notVisiblePorts);
                }
                Set<String> supportedProtocols = (hasSCSIInitiators) ? SCALEIO_AND_ISCSI : SCALEIO_ONLY;
                List<ScaleIOStoragePool> storagePools = scaleIOHandle.getProtectionDomainStoragePools(protectionDomainId);
                for (ScaleIOStoragePool storagePool : storagePools) {
                    String poolName = storagePool.getName();
                    String nativeGuid = String.format("%s-%s-%s", installationId, domainName, poolName);
                    log.info("Attempting to discover pool {} for ProtectionDomain {}", poolName, domainName);
                    List<StoragePool> pools = queryActiveResourcesByAltId(_dbClient, StoragePool.class, "nativeGuid", nativeGuid);
                    StoragePool pool = null;
                    if (pools.isEmpty()) {
                        log.info("Pool {} is new", poolName);
                        pool = new StoragePool();
                        pool.setId(URIUtil.createId(StoragePool.class));
                        pool.setStorageDevice(accessProfile.getSystemId());
                        pool.setPoolServiceType(StoragePool.PoolServiceType.block.toString());
                        pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
                        pool.setCompatibilityStatus(compatibilityStatus.name());
                        pool.setThinVolumePreAllocationSupported(false);
                        pool.addDriveTypes(Collections.singleton(StoragePool.SupportedDriveTypeValues.SATA.name()));
                        StringSet copyTypes = new StringSet();
                        copyTypes.add(StoragePool.CopyTypes.ASYNC.name());
                        copyTypes.add(StoragePool.CopyTypes.UNSYNC_UNASSOC.name());
                        pool.setSupportedCopyTypes(copyTypes);
                        pool.setMaximumThickVolumeSize(1048576L);
                        pool.setMinimumThickVolumeSize(1L);
                        newPools.add(pool);
                    } else if (pools.size() == 1) {
                        log.info("Pool {} was previously discovered", storagePool);
                        pool = pools.get(0);
                        updatePools.add(pool);
                    } else {
                        log.warn(String.format("There are %d StoragePools with nativeGuid = %s", pools.size(), nativeGuid));
                        continue;
                    }
                    pool.setPoolName(poolName);
                    pool.setNativeId(storagePool.getId());
                    pool.setNativeGuid(nativeGuid);
                    String availableCapacityString = storagePool.getCapacityAvailableForVolumeAllocationInKb();
                    pool.setFreeCapacity(Long.parseLong(availableCapacityString));
                    String totalCapacityString = storagePool.getMaxCapacityInKb();
                    pool.setTotalCapacity(Long.parseLong(totalCapacityString));
                    pool.addProtocols(supportedProtocols);
                    pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.name());
                    Long maxThinSize = 1048576L;
                    Long minThinSize = 1L;
                    pool.setMaximumThinVolumeSize(maxThinSize);
                    pool.setMinimumThinVolumeSize(minThinSize);
                    pool.setInactive(false);
                    pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
                }
            }
            log.info(String.format("For StorageSystem %s, discovered %d new pools and %d pools to update", storageSystem.getNativeGuid(), newPools.size(), updatePools.size()));
            StoragePoolAssociationHelper.setStoragePoolVarrays(storageSystem.getId(), newPools, _dbClient);
            allPools.addAll(newPools);
            allPools.addAll(updatePools);
            _dbClient.createObject(newPools);
            _dbClient.updateAndReindexObject(updatePools);
            List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystem.getId());
            if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
                allPools.addAll(notVisiblePools);
            }
            StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports, null, _dbClient, _coordinator, allPools);
            statusMsg = String.format("Discovery completed successfully for Storage System: %s", storageSystem.getNativeGuid());
        }
    } catch (Exception e) {
        storageSystem.setReachableStatus(false);
        log.error(String.format("Exception was encountered when attempting to discover ScaleIO Instance %s", accessProfile.getIpAddress()), e);
        statusMsg = String.format("Discovery failed because %s", e.getLocalizedMessage());
        throw ScaleIOException.exceptions.discoveryFailed(e);
    } finally {
        _locker.releaseLock(accessProfile.getIpAddress());
        if (storageSystem != null) {
            storageSystem.setLastDiscoveryStatusMessage(statusMsg);
        }
    }
    _dbClient.updateAndReindexObject(storageSystem);
    log.info("Completed of ScaleIO StorageProvider. IP={} StorageSystem {}", accessProfile.getIpAddress(), storageSystem.getNativeGuid());
}
Also used : ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) ArrayList(java.util.ArrayList) ScaleIOSystem(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem) ScaleIOProtectionDomain(com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain) ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) ScaleIOSDS(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS) IOException(java.io.IOException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException) ScaleIOScsiInitiator(com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator) ScaleIORestClient(com.emc.storageos.scaleio.api.restapi.ScaleIORestClient) ScaleIOSDC(com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC)

Example 8 with ScaleIOStoragePool

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool in project coprhd-controller by CoprHD.

the class ScaleIOHelper method updateStoragePoolCapacity.

public static void updateStoragePoolCapacity(DbClient dbClient, ScaleIORestClient scaleIOHandle, StoragePool storagePool, StorageSystem storage) {
    try {
        log.info(String.format("Old storage pool capacity data for %n  pool %s/%s --- %n  free capacity: %s; subscribed capacity: %s", storage.getId(), storagePool.getId(), storagePool.calculateFreeCapacityWithoutReservations(), storagePool.getSubscribedCapacity()));
        ScaleIOStoragePool storagePoolResult = scaleIOHandle.queryStoragePool(storagePool.getNativeId());
        storagePool.setFreeCapacity(Long.parseLong(storagePoolResult.getCapacityAvailableForVolumeAllocationInKb()));
        storagePool.setTotalCapacity(Long.parseLong(storagePoolResult.getMaxCapacityInKb()));
        log.info(String.format("New storage pool capacity data for pool %n  %s/%s --- %n  free capacity: %s; subscribed capacity: %s", storage.getId(), storagePool.getId(), storagePool.getFreeCapacity(), storagePool.getSubscribedCapacity()));
        dbClient.persistObject(storagePool);
    } catch (Exception e) {
        StringBuilder sb = new StringBuilder();
        sb.append("Failed to update capacity of storage pool after volume provisioning operation.\n");
        sb.append("Storage system: %s, storage pool %s.");
        log.error(String.format(sb.toString(), storage.getId(), storagePool.getId()), e);
    }
}
Also used : ScaleIOStoragePool(com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool) IOException(java.io.IOException)

Aggregations

ScaleIOStoragePool (com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)8 ScaleIOProtectionDomain (com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain)3 ScaleIOSDS (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS)3 ClientResponse (com.sun.jersey.api.client.ClientResponse)3 ScaleIOException (com.emc.storageos.scaleio.ScaleIOException)2 ScaleIORestClient (com.emc.storageos.scaleio.api.restapi.ScaleIORestClient)2 ScaleIODevice (com.emc.storageos.scaleio.api.restapi.response.ScaleIODevice)2 ScaleIOFaultSet (com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet)2 ScaleIOSDC (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC)2 ScaleIOSystem (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 ScaleIODataMapper (com.emc.storageos.api.mapper.ScaleIODataMapper)1 ScaleIOCollectDataParam (com.emc.storageos.model.collectdata.ScaleIOCollectDataParam)1 ScaleIODeviceDataRestRep (com.emc.storageos.model.collectdata.ScaleIODeviceDataRestRep)1 ScaleIOSDCDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDCDataRestRep)1 ScaleIOSDSDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSDSDataRestRep)1 ScaleIOSystemDataRestRep (com.emc.storageos.model.collectdata.ScaleIOSystemDataRestRep)1 ScaleIOVolumeDataRestRep (com.emc.storageos.model.collectdata.ScaleIOVolumeDataRestRep)1 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1