Search in sources :

Example 66 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class RemoteMirrorProtectionValidator method validateSRDFTargetAsVMAX.

// Only vmax arrays allowed as srdf targets
private void validateSRDFTargetAsVMAX(URI virtualPool, DbClient dbClient) {
    if (null != virtualPool) {
        VirtualPool targetVPool = dbClient.queryObject(VirtualPool.class, virtualPool);
        List<StoragePool> targetPools = VirtualPool.getValidStoragePools(targetVPool, dbClient, true);
        for (StoragePool targetPool : targetPools) {
            if (!targetPool.getNativeGuid().toUpperCase().contains(SYMMETRIX)) {
                throw APIException.badRequests.vmaxAllowedOnlyAsSrdfTargets();
            }
        }
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 67 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class BlockDeviceController method expandVolume.

@Override
public void expandVolume(URI storage, URI pool, URI volume, Long size, String opId) throws ControllerException {
    try {
        StorageSystem storageObj = _dbClient.queryObject(StorageSystem.class, storage);
        Volume volumeObj = _dbClient.queryObject(Volume.class, volume);
        _log.info(String.format("expandVolume start - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, OldSize: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getCapacity(), size));
        StoragePool poolObj = _dbClient.queryObject(StoragePool.class, pool);
        VolumeExpandCompleter completer = new VolumeExpandCompleter(volume, size, opId);
        long metaMemberSize = volumeObj.getIsComposite() ? volumeObj.getMetaMemberSize() : volumeObj.getCapacity();
        long metaCapacity = volumeObj.getIsComposite() ? volumeObj.getTotalMetaMemberCapacity() : volumeObj.getCapacity();
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volumeObj.getVirtualPool());
        boolean isThinlyProvisioned = volumeObj.getThinlyProvisioned();
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getExpandRecommendation(storageObj, poolObj, metaCapacity, size, metaMemberSize, isThinlyProvisioned, vpool.getFastExpansion());
        if (recommendation.isCreateMetaVolumes()) {
            // Also check that this is not recovery to clean dangling meta volumes with zero-capacity expansion.
            if (recommendation.getMetaMemberCount() == 0 && (volumeObj.getMetaVolumeMembers() == null || volumeObj.getMetaVolumeMembers().isEmpty())) {
                volumeObj.setCapacity(size);
                _dbClient.updateObject(volumeObj);
                _log.info(String.format("Expanded volume within its total meta volume capacity (simple case) - Array: %s Pool:%s Volume:%s, IsMetaVolume: %s, Total meta volume capacity: %s, NewSize: %s", storage.toString(), pool.toString(), volume.toString(), volumeObj.getIsComposite(), volumeObj.getTotalMetaMemberCapacity(), volumeObj.getCapacity()));
                completer.ready(_dbClient);
            } else {
                // set meta related data in task completer
                long metaMemberCount = volumeObj.getIsComposite() ? recommendation.getMetaMemberCount() + volumeObj.getMetaMemberCount() : recommendation.getMetaMemberCount() + 1;
                completer.setMetaMemberSize(recommendation.getMetaMemberSize());
                completer.setMetaMemberCount((int) metaMemberCount);
                completer.setTotalMetaMembersSize(metaMemberCount * recommendation.getMetaMemberSize());
                completer.setComposite(true);
                completer.setMetaVolumeType(recommendation.getMetaVolumeType().toString());
                getDevice(storageObj.getSystemType()).doExpandAsMetaVolume(storageObj, poolObj, volumeObj, size, recommendation, completer);
            }
        } else {
            // expand as regular volume
            InvokeTestFailure.internalOnlyInvokeTestFailure(InvokeTestFailure.ARTIFICIAL_FAILURE_080);
            getDevice(storageObj.getSystemType()).doExpandVolume(storageObj, poolObj, volumeObj, size, completer);
        }
        _log.info(String.format("expandVolume end - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()));
    } catch (Exception e) {
        _log.error(String.format("expandVolume Failed - Array: %s Pool:%s Volume:%s", storage.toString(), pool.toString(), volume.toString()), e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        List<URI> volumes = Arrays.asList(volume);
        doFailTask(Volume.class, volumes, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) VolumeExpandCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeExpandCompleter) Arrays.asList(java.util.Arrays.asList) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 68 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class BlockDeviceController method createMetaVolumes.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMetaVolumesMethod just above
 * (except opId).
 */
@Override
public void createMetaVolumes(URI systemURI, URI poolURI, List<URI> volumeURIs, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    boolean opCreateFailed = false;
    List<Volume> volumes = new ArrayList<Volume>();
    try {
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        List<VolumeTaskCompleter> volumeCompleters = new ArrayList<VolumeTaskCompleter>();
        Iterator<URI> volumeURIsIter = volumeURIs.iterator();
        StringBuilder logMsgBuilder = new StringBuilder(String.format("createMetaVolumes start - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        while (volumeURIsIter.hasNext()) {
            URI volumeURI = volumeURIsIter.next();
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURI.toString()));
            Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
            volumes.add(volume);
            VolumeCreateCompleter volumeCompleter = new VolumeCreateCompleter(volumeURI, opId);
            volumeCompleters.add(volumeCompleter);
        }
        _log.info(logMsgBuilder.toString());
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
        MultiVolumeTaskCompleter completer = new MultiVolumeTaskCompleter(volumeURIs, volumeCompleters, opId);
        Volume volume = volumes.get(0);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        // All volumes are in the same storage pool with the same capacity. Get recommendation for the first volume.
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, volume.getCapacity(), volume.getThinlyProvisioned(), vpool.getFastExpansion(), capabilities);
        for (Volume metaVolume : volumes) {
            MetaVolumeUtils.prepareMetaVolume(metaVolume, recommendation.getMetaMemberSize(), recommendation.getMetaMemberCount(), recommendation.getMetaVolumeType().toString(), _dbClient);
        }
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        getDevice(storageSystem.getSystemType()).doCreateMetaVolumes(storageSystem, storagePool, volumes, capabilities, recommendation, completer);
        logMsgBuilder = new StringBuilder(String.format("createMetaVolumes end - Array:%s Pool:%s", systemURI.toString(), poolURI.toString()));
        volumeURIsIter = volumeURIs.iterator();
        while (volumeURIsIter.hasNext()) {
            logMsgBuilder.append(String.format("%nVolume:%s", volumeURIsIter.next().toString()));
        }
        _log.info(logMsgBuilder.toString());
    } catch (InternalException e) {
        _log.error(String.format("createMetaVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        doFailTask(Volume.class, volumeURIs, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
        opCreateFailed = true;
    } catch (Exception e) {
        _log.error(String.format("createMetaVolumes Failed - Array: %s Pool:%s Volume:%s", systemURI.toString(), poolURI.toString(), Joiner.on("\t").join(volumeURIs)));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURIs, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
        opCreateFailed = true;
    }
    if (opCreateFailed) {
        for (Volume volume : volumes) {
            volume.setInactive(true);
            _dbClient.updateObject(volume);
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) FCTN_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_MIRROR_TO_URI) URI(java.net.URI) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) VolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeTaskCompleter) MultiVolumeTaskCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.MultiVolumeTaskCompleter) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 69 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class BlockDeviceController method createMetaVolume.

/**
 * {@inheritDoc} NOTE NOTE: The signature here MUST match the Workflow.Method createMetaVolumeMethod just above
 * (except opId).
 */
@Override
public void createMetaVolume(URI systemURI, URI poolURI, URI volumeURI, VirtualPoolCapabilityValuesWrapper capabilities, String opId) throws ControllerException {
    try {
        StringBuilder logMsgBuilder = new StringBuilder(String.format("createMetaVolume start - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        _log.info(logMsgBuilder.toString());
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemURI);
        Volume volume = _dbClient.queryObject(Volume.class, volumeURI);
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, poolURI);
        VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
        MetaVolumeRecommendation recommendation = MetaVolumeUtils.getCreateRecommendation(storageSystem, storagePool, volume.getCapacity(), volume.getThinlyProvisioned(), vpool.getFastExpansion(), capabilities);
        MetaVolumeUtils.prepareMetaVolume(volume, recommendation.getMetaMemberSize(), recommendation.getMetaMemberCount(), recommendation.getMetaVolumeType().toString(), _dbClient);
        VolumeCreateCompleter completer = new VolumeCreateCompleter(volumeURI, opId);
        WorkflowStepCompleter.stepExecuting(completer.getOpId());
        getDevice(storageSystem.getSystemType()).doCreateMetaVolume(storageSystem, storagePool, volume, capabilities, recommendation, completer);
        logMsgBuilder = new StringBuilder(String.format("createMetaVolume end - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        _log.info(logMsgBuilder.toString());
    } catch (InternalException e) {
        _log.error(String.format("createMetaVolume Failed - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        doFailTask(Volume.class, volumeURI, opId, e);
        WorkflowStepCompleter.stepFailed(opId, e);
    } catch (Exception e) {
        _log.error(String.format("createMetaVolume Failed - Array:%s Pool:%s, Volume:%s", systemURI.toString(), poolURI.toString(), volumeURI.toString()));
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        doFailTask(Volume.class, volumeURI, opId, serviceError);
        WorkflowStepCompleter.stepFailed(opId, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) VolumeCreateCompleter(com.emc.storageos.volumecontroller.impl.block.taskcompleter.VolumeCreateCompleter) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) MetaVolumeRecommendation(com.emc.storageos.volumecontroller.impl.smis.MetaVolumeRecommendation) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) DataBindingException(javax.xml.bind.DataBindingException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 70 with StoragePool

use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.

the class HDSVolumeDiscoverer method discoverUnManagedVolumes.

public void discoverUnManagedVolumes(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedVolumes for system {}", accessProfile.getSystemId());
    HDSApiClient hdsApiClient = hdsApiFactory.getClient(HDSUtils.getHDSServerManagementServerInfo(accessProfile), accessProfile.getUserName(), accessProfile.getPassword());
    List<UnManagedVolume> newUnManagedVolumeList = new ArrayList<UnManagedVolume>();
    List<UnManagedVolume> updateUnManagedVolumeList = new ArrayList<UnManagedVolume>();
    Set<URI> allDiscoveredUnManagedVolumes = new HashSet<URI>();
    HDSApiVolumeManager volumeManager = hdsApiClient.getHDSApiVolumeManager();
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    String systemObjectId = HDSUtils.getSystemObjectID(storageSystem);
    List<LogicalUnit> luList = volumeManager.getAllLogicalUnits(systemObjectId);
    if (null != luList && !luList.isEmpty()) {
        log.info("Processing {} volumes received from HiCommand server.", luList.size());
        URIQueryResultList storagePoolURIs = new URIQueryResultList();
        dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceStoragePoolConstraint(storageSystem.getId()), storagePoolURIs);
        HashMap<String, StoragePool> pools = new HashMap<String, StoragePool>();
        Iterator<URI> poolsItr = storagePoolURIs.iterator();
        while (poolsItr.hasNext()) {
            URI storagePoolURI = poolsItr.next();
            StoragePool storagePool = dbClient.queryObject(StoragePool.class, storagePoolURI);
            pools.put(storagePool.getNativeGuid(), storagePool);
        }
        for (LogicalUnit logicalUnit : luList) {
            log.info("Processing LogicalUnit: {}", logicalUnit.getObjectID());
            UnManagedVolume unManagedVolume = null;
            String managedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
            if (null != DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedVolumeNativeGuid)) {
                log.info("Skipping volume {} as it is already managed by ViPR", managedVolumeNativeGuid);
            }
            String unManagedVolumeNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), String.valueOf(logicalUnit.getDevNum()));
            unManagedVolume = DiscoveryUtils.checkUnManagedVolumeExistsInDB(dbClient, unManagedVolumeNativeGuid);
            boolean unManagedVolumeExists = (null != unManagedVolume) ? true : false;
            StoragePool storagePool = getStoragePoolOfUnManagedVolume(logicalUnit, storageSystem, pools, dbClient);
            if (null != storagePool) {
                if (!unManagedVolumeExists) {
                    unManagedVolume = createUnManagedVolume(unManagedVolumeNativeGuid, logicalUnit, storageSystem, storagePool, dbClient);
                    newUnManagedVolumeList.add(unManagedVolume);
                } else {
                    updateUnManagedVolumeInfo(logicalUnit, storageSystem, storagePool, unManagedVolume, dbClient);
                    updateUnManagedVolumeList.add(unManagedVolume);
                }
                allDiscoveredUnManagedVolumes.add(unManagedVolume.getId());
            } else {
                log.error("Skipping unmanaged volume discovery as the volume {} storage pool doesn't exist in ViPR", logicalUnit.getObjectID());
            }
            performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, Constants.DEFAULT_PARTITION_SIZE);
        }
        performUnManagedVolumesBookKeepting(newUnManagedVolumeList, updateUnManagedVolumeList, partitionManager, dbClient, 0);
        // Process those active unmanaged volume objects available in database but not in newly discovered items, to mark them inactive.
        DiscoveryUtils.markInActiveUnManagedVolumes(storageSystem, allDiscoveredUnManagedVolumes, dbClient, partitionManager);
    } else {
        log.info("No volumes retured by HiCommand Server for system {}", storageSystem.getId());
    }
}
Also used : HDSApiVolumeManager(com.emc.storageos.hds.api.HDSApiVolumeManager) HDSApiClient(com.emc.storageos.hds.api.HDSApiClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) LogicalUnit(com.emc.storageos.hds.model.LogicalUnit) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

StoragePool (com.emc.storageos.db.client.model.StoragePool)386 URI (java.net.URI)196 ArrayList (java.util.ArrayList)189 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)159 StringSet (com.emc.storageos.db.client.model.StringSet)86 HashMap (java.util.HashMap)85 List (java.util.List)80 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)77 HashSet (java.util.HashSet)75 Volume (com.emc.storageos.db.client.model.Volume)72 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)57 NamedURI (com.emc.storageos.db.client.model.NamedURI)52 StoragePort (com.emc.storageos.db.client.model.StoragePort)51 StringMap (com.emc.storageos.db.client.model.StringMap)47 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)47 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)43 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)43 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)39 IOException (java.io.IOException)35 CIMObjectPath (javax.cim.CIMObjectPath)30