Search in sources :

Example 1 with ScaleIOScsiInitiator

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

the class ScaleIORestClient method queryAllSCSIInitiators.

/**
 * Query all SCSI Initiators
 *
 * @return The list of the ScaleIOScsiInitiator
 * @throws JSONException
 */
public List<ScaleIOScsiInitiator> queryAllSCSIInitiators() throws JSONException {
    log.info("Discovery all SCSI Initiators");
    List<ScaleIOScsiInitiator> scsiInits = Collections.emptyList();
    try {
        ClientResponse response = get(URI.create(ScaleIOConstants.GET_SCSI_INITIATOR_URI));
        scsiInits = getResponseObjects(ScaleIOScsiInitiator.class, response);
    } catch (Exception e) {
        // 1.32 and later does not support get ScsiInitiators
        log.debug("This exception is expected for ScaleIO 1.32 and later, since iSCSI supported is removed. Exception:", e);
    }
    return scsiInits;
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ScaleIOScsiInitiator(com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator) JSONException(org.codehaus.jettison.json.JSONException) ScaleIOException(com.emc.storageos.scaleio.ScaleIOException)

Example 2 with ScaleIOScsiInitiator

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

the class ScaleIOCommunicationInterface method createSCSIInitiatorsAndStoragePorts.

/**
 * This will create an IP network for the SIO system to contain the iSCSI initiators
 * associated with the system (if any). It will also create the iSCSI initiators and
 * StoragePorts, placing them in the IP network.
 *
 * @param storageSystem [in] - StorageSystem object (ProtectionDomain)
 * @param protectionDomainName [in] - Protection Domain name
 * @param compatibilityStatus [in] - Compatibility status to use on the ports
 * @param installationId [in] - Installation ID unique to ScaleIO instance
 * @param queryAllSCSIInitiatorsResult [in] - Result of querying ScaleIO for SCSI initiators
 * @param queryAllSDCResult [in] - Result of querying ScaleIO for SDC clients
 * @param ports [out] - List to update with iSCSI StoragePorts that were discovered
 * @return - true if there were SCSI initiators found on the system.
 * @throws IOException
 */
private boolean createSCSIInitiatorsAndStoragePorts(StorageSystem storageSystem, String protectionDomainName, DiscoveredDataObject.CompatibilityStatus compatibilityStatus, String installationId, List<ScaleIOScsiInitiator> allSCSIInitiators, List<ScaleIOSDC> allSDCs, List<StoragePort> ports) throws IOException {
    boolean hasSCSIInitiators = false;
    if (allSDCs != null && allSCSIInitiators != null && !allSCSIInitiators.isEmpty()) {
        List<String> initiatorsToAddToNetwork = new ArrayList<>();
        String networkId = String.format("%s-IP", installationId);
        Network networkForSCSIInitiators = createIPNetworkForSCSIInitiators(networkId);
        for (ScaleIOScsiInitiator scsiInit : allSCSIInitiators) {
            String id = scsiInit.getId();
            String iqn = scsiInit.getIqn();
            Initiator initiator = createSCSIInitiator(iqn, id);
            if (!networkForSCSIInitiators.hasEndpoint(initiator.getInitiatorPort())) {
                initiatorsToAddToNetwork.add(initiator.getInitiatorPort());
            }
            hasSCSIInitiators = true;
        }
        if (!initiatorsToAddToNetwork.isEmpty()) {
            networkForSCSIInitiators.addEndpoints(initiatorsToAddToNetwork, true);
            _dbClient.updateAndReindexObject(networkForSCSIInitiators);
        }
        List<StoragePort> iSCSIPorts = createSCSIStoragePorts(storageSystem, protectionDomainName, compatibilityStatus, networkForSCSIInitiators, allSDCs);
        ports.addAll(iSCSIPorts);
    }
    return hasSCSIInitiators;
}
Also used : ScaleIOScsiInitiator(com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator) ArrayList(java.util.ArrayList) ScaleIOScsiInitiator(com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator)

Example 3 with ScaleIOScsiInitiator

use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator 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)

Aggregations

ScaleIOScsiInitiator (com.emc.storageos.scaleio.api.restapi.response.ScaleIOScsiInitiator)3 ScaleIOException (com.emc.storageos.scaleio.ScaleIOException)2 ArrayList (java.util.ArrayList)2 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)1 ScaleIORestClient (com.emc.storageos.scaleio.api.restapi.ScaleIORestClient)1 ScaleIOProtectionDomain (com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain)1 ScaleIOSDC (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDC)1 ScaleIOSDS (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS)1 ScaleIOStoragePool (com.emc.storageos.scaleio.api.restapi.response.ScaleIOStoragePool)1 ScaleIOSystem (com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem)1 ClientResponse (com.sun.jersey.api.client.ClientResponse)1 IOException (java.io.IOException)1 JSONException (org.codehaus.jettison.json.JSONException)1