Search in sources :

Example 96 with VirtualPool

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

the class BlockFullCopyManager method getPlatformSpecificFullCopyImpl.

/**
 * Determines and returns the platform specific full copy implementation.
 *
 * @param fcSourceObj A reference to the full copy source.
 *
 * @return The platform specific full copy implementation
 */
private BlockFullCopyApi getPlatformSpecificFullCopyImpl(BlockObject fcSourceObj) {
    BlockFullCopyApi fullCopyApi = null;
    if (BlockObject.checkForRP(_dbClient, fcSourceObj.getId())) {
        fullCopyApi = _fullCopyImpls.get(FullCopyImpl.rp.name());
    } else {
        VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
        if (VirtualPool.vPoolSpecifiesHighAvailability(vpool)) {
            fullCopyApi = _fullCopyImpls.get(FullCopyImpl.vplex.name());
        } else {
            URI systemURI = fcSourceObj.getStorageController();
            StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
            return getPlatformSpecificFullCopyImplForSystem(system);
        }
    }
    return fullCopyApi;
}
Also used : VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 97 with VirtualPool

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

the class BlockFullCopyUtils method queryFullCopySourceVPool.

/**
 * Returns the vpool for the full copy source.
 *
 * @param fcSourceObj A reference to the Volume or BlockSnapshot instance.
 * @param dbClient A reference to a database client.
 *
 * @return A reference to the vpool for the full copy source.
 */
public static VirtualPool queryFullCopySourceVPool(BlockObject fcSourceObj, DbClient dbClient) {
    URI fcSourceURI = fcSourceObj.getId();
    URI vpoolURI = null;
    if (URIUtil.isType(fcSourceURI, Volume.class)) {
        vpoolURI = ((Volume) fcSourceObj).getVirtualPool();
    } else if (URIUtil.isType(fcSourceURI, BlockSnapshot.class)) {
        URI parentVolURI = ((BlockSnapshot) fcSourceObj).getParent().getURI();
        Volume parentVolume = dbClient.queryObject(Volume.class, parentVolURI);
        vpoolURI = parentVolume.getVirtualPool();
    }
    if (vpoolURI == null) {
        throw APIException.badRequests.invalidFullCopySource(fcSourceURI.toString());
    }
    VirtualPool vpool = dbClient.queryObject(VirtualPool.class, vpoolURI);
    return vpool;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI)

Example 98 with VirtualPool

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

the class DefaultBlockFullCopyApiImpl method create.

/**
 * {@inheritDoc}
 */
@Override
public TaskList create(List<BlockObject> fcSourceObjList, VirtualArray varray, String name, boolean createInactive, int count, String taskId) {
    // Get the placement recommendations for the full copies and
    // prepare the ViPR volumes to represent the full copies.
    // TBD We are getting recommendations one at a time instead
    // of for all full copies at the same time as was done
    // previously. However, now we are allowing for creating
    // full copies for multiple volume form a CG. These volumes
    // could have different vpools and sizes. Therefore, I don't
    // see how we can get them at the same time for all volumes
    // as the capabilities could be different. I guess the
    // possible result is that if the volumes are the same, they
    // could be placed in the same storage pool and if the pool
    // is approaching capacity, there may not actually be enough
    // space in the recommended pool.
    int sourceCounter = 0;
    List<Volume> volumesList = new ArrayList<Volume>();
    BlockObject aFCSource = null;
    Map<URI, VirtualArray> vArrayCache = new HashMap<URI, VirtualArray>();
    List<BlockObject> sortedSourceObjectList = sortFullCopySourceList(fcSourceObjList);
    try {
        for (BlockObject fcSourceObj : sortedSourceObjectList) {
            // Make sure when there are multiple source objects,
            // each full copy has a unique name.
            aFCSource = fcSourceObj;
            // volumes in VolumeGroup can be from different vArrays
            varray = getVarrayFromCache(vArrayCache, fcSourceObj.getVirtualArray());
            String copyName = null;
            boolean inApplication = false;
            if (aFCSource instanceof Volume && ((Volume) aFCSource).getApplication(_dbClient) != null) {
                inApplication = true;
            }
            if (NullColumnValueGetter.isNotNullValue(fcSourceObj.getReplicationGroupInstance()) && inApplication) {
                copyName = name + "-" + fcSourceObj.getReplicationGroupInstance() + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
            } else {
                copyName = name + (sortedSourceObjectList.size() > 1 ? "-" + ++sourceCounter : "");
            }
            VirtualPool vpool = BlockFullCopyUtils.queryFullCopySourceVPool(fcSourceObj, _dbClient);
            VirtualPoolCapabilityValuesWrapper capabilities = getCapabilitiesForFullCopyCreate(fcSourceObj, vpool, count);
            List<VolumeRecommendation> placementRecommendations = getPlacementRecommendations(fcSourceObj, capabilities, varray, vpool.getId());
            volumesList.addAll(prepareClonesForEachRecommendation(copyName, name, fcSourceObj, capabilities, createInactive, placementRecommendations));
        }
    } catch (Exception ex) {
        handlePlacementFailure(volumesList);
        throw ex;
    }
    // get volume descriptors
    List<VolumeDescriptor> volumeDescriptors = prepareVolumeDescriptorsForFullCopy(volumesList, createInactive);
    // get all tasks
    TaskList tasks = getTasksForCreateFullCopy(aFCSource, volumesList, taskId);
    try {
        BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
        controller.createFullCopy(volumeDescriptors, taskId);
    } catch (InternalException ie) {
        handleFailedRequest(taskId, tasks, volumesList, ie, true);
    }
    return tasks;
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) HashMap(java.util.HashMap) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 99 with VirtualPool

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

the class DefaultBlockFullCopyApiImpl method getPlacementRecommendations.

/**
 * Get the placement recommendations for the passed full copy source.
 *
 * @param blockObject A reference to the full copy source.
 * @param capabilities Encapsulates the copy capabilities
 * @param varray A reference to the virtual array.
 * @param vpoolURI The URI of the virtual pool for the source.
 *
 * @return A list of volume placement recommendations.
 */
private List<VolumeRecommendation> getPlacementRecommendations(BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities, VirtualArray varray, URI vpoolURI) {
    // Find placement for block volume copies
    VirtualPool vPool = _dbClient.queryObject(VirtualPool.class, vpoolURI);
    List<VolumeRecommendation> placementRecommendations = ((StorageScheduler) _scheduler).getRecommendationsForVolumeClones(varray, vPool, blockObject, capabilities);
    if (placementRecommendations.isEmpty()) {
        throw APIException.badRequests.invalidParameterNoStorageFoundForVolume(varray.getId(), vPool.getId(), blockObject.getId());
    }
    return placementRecommendations;
}
Also used : StorageScheduler(com.emc.storageos.api.service.impl.placement.StorageScheduler) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation)

Example 100 with VirtualPool

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

the class RemoteReplicationIngestor method runRemoteReplicationStepsOnTarget.

/**
 * If unmanaged volume is a Target Volume, then 1. Find if source is ingested 2. If yes, then
 * find whether expected targets of this source had been ingested already excluding the current
 * target. 3. If yes, establish links between source and targets. 4. If not,then make sure
 * unmanaged volume hasn't been deleted.
 *
 * @param unManagedVolume
 * @param volume
 * @param unManagedVolumes
 * @param type
 * @return
 */
@SuppressWarnings("deprecation")
private static boolean runRemoteReplicationStepsOnTarget(UnManagedVolume unManagedVolume, Volume volume, List<UnManagedVolume> unManagedVolumes, String type, DbClient dbClient) {
    boolean removeUnManagedVolume = false;
    StringSetMap unManagedVolumeInformation = unManagedVolume.getVolumeInformation();
    String sourceUnManagedVolumeId = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_SOURCE_VOLUME.toString(), unManagedVolumeInformation);
    _logger.info("Type {} Source Native Guid {}", type, sourceUnManagedVolumeId);
    String sourceVolumeId = sourceUnManagedVolumeId.replace(VolumeIngestionUtil.UNMANAGEDVOLUME, VolumeIngestionUtil.VOLUME);
    List<URI> sourceUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeNativeGuidConstraint(sourceVolumeId));
    String copyMode = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_COPY_MODE.toString(), unManagedVolumeInformation);
    String raGroup = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.REMOTE_MIRROR_RDF_GROUP.toString(), unManagedVolumeInformation);
    volume.setSrdfCopyMode(copyMode);
    volume.setSrdfGroup(URI.create(raGroup));
    if (sourceUris.isEmpty()) {
        _logger.info("Source {} Not found for target {}", sourceVolumeId, volume.getId());
    } else {
        // check whether all targets of the source are ingested
        List<URI> sourceUnmanagedUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getVolumeInfoNativeIdConstraint(sourceUnManagedVolumeId));
        if (!sourceUnmanagedUris.isEmpty()) {
            UnManagedVolume sourceUnManagedVolume = dbClient.queryObject(UnManagedVolume.class, sourceUnmanagedUris.get(0));
            if (null != sourceUnManagedVolume) {
                StringSet targetUnManagedVolumeGuids = sourceUnManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.REMOTE_MIRRORS.toString());
                if (null != targetUnManagedVolumeGuids && !targetUnManagedVolumeGuids.isEmpty()) {
                    StringSet targetVolumeNativeGuids = VolumeIngestionUtil.getListofVolumeIds(targetUnManagedVolumeGuids);
                    List<URI> targetUris = VolumeIngestionUtil.getVolumeUris(targetVolumeNativeGuids, dbClient);
                    targetUris.add(volume.getId());
                    _logger.info("Expected targets Size {} , found {} ", targetUnManagedVolumeGuids.size(), targetUris.size());
                    _logger.debug("Expected Targets {} : Found {}", Joiner.on("\t").join(targetVolumeNativeGuids), Joiner.on("\t").join(targetUris));
                    List<Volume> modifiedVolumes = new ArrayList<Volume>();
                    if (targetUris.size() == targetUnManagedVolumeGuids.size()) {
                        // if all other targets are ingested, then
                        Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUris.get(0));
                        // check whether the source Volume's VPool is actually having this target Volume's varray
                        // specified as remote
                        VirtualPool sourceVPool = dbClient.queryObject(VirtualPool.class, sourceVolume.getVirtualPool());
                        Map<URI, VpoolRemoteCopyProtectionSettings> settings = sourceVPool.getRemoteProtectionSettings(sourceVPool, dbClient);
                        if (null == settings || settings.size() == 0 || !settings.containsKey(volume.getVirtualArray())) {
                            _logger.info("Target Volume's VArray {} is not matching already ingested source volume virtual pool's remote VArray ", volume.getVirtualArray());
                            return false;
                        }
                        sourceVolume.setSrdfTargets(VolumeIngestionUtil.convertUrisToStrings(targetUris));
                        _logger.info("Clearing internal flag for source volume {} found", sourceVolume.getNativeGuid());
                        sourceVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                        _logger.debug("Set srdf target for source volume {} found", sourceVolume.getId());
                        modifiedVolumes.add(sourceVolume);
                        // source unmanagedVolume
                        sourceUnManagedVolume.setInactive(true);
                        unManagedVolumes.add(sourceUnManagedVolume);
                        // this target unmanaged volume
                        volume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
                        _logger.debug("target volume  set parent", volume.getId());
                        removeUnManagedVolume = true;
                        // handle other target volumes
                        List<Volume> targetVolumes = dbClient.queryObject(Volume.class, targetUris);
                        for (Volume targetVolume : targetVolumes) {
                            _logger.debug("Set parent for remaining target volume {}", targetVolume.getId());
                            targetVolume.setSrdfParent(new NamedURI(sourceVolume.getId(), sourceVolume.getLabel()));
                            targetVolume.clearInternalFlags(INTERNAL_VOLUME_FLAGS);
                        }
                        modifiedVolumes.addAll(targetVolumes);
                        // target unmanaged volumes
                        List<UnManagedVolume> targetUnManagedVolumes = dbClient.queryObject(UnManagedVolume.class, VolumeIngestionUtil.getUnManagedVolumeUris(targetUnManagedVolumeGuids, dbClient));
                        for (UnManagedVolume targetUnManagedVol : targetUnManagedVolumes) {
                            _logger.debug("Set Target unmanaged volume inactive {}", targetUnManagedVol.getId());
                            targetUnManagedVol.setInactive(true);
                            unManagedVolumes.add(targetUnManagedVol);
                        }
                        dbClient.persistObject(modifiedVolumes);
                        _logger.info("Target Volume successfully ingested with remote replication links", volume.getNativeGuid());
                    } else {
                        // set volume flag to false
                        _logger.info("Expected Targets not found for source Volume {}", sourceUnManagedVolumeId);
                    }
                } else {
                    _logger.info("Targets information not found on source volume {}." + "This could happen when parallel ingests are tried or the actual volume got deleted on array.", sourceUnManagedVolumeId);
                }
            }
        }
    }
    return removeUnManagedVolume;
}
Also used : StringSetMap(com.emc.storageos.db.client.model.StringSetMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) NamedURI(com.emc.storageos.db.client.model.NamedURI) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet)

Aggregations

VirtualPool (com.emc.storageos.db.client.model.VirtualPool)339 URI (java.net.URI)189 ArrayList (java.util.ArrayList)122 Volume (com.emc.storageos.db.client.model.Volume)103 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)92 NamedURI (com.emc.storageos.db.client.model.NamedURI)88 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)88 StringSet (com.emc.storageos.db.client.model.StringSet)76 Project (com.emc.storageos.db.client.model.Project)65 StoragePool (com.emc.storageos.db.client.model.StoragePool)57 StringMap (com.emc.storageos.db.client.model.StringMap)53 HashMap (java.util.HashMap)52 Produces (javax.ws.rs.Produces)50 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)45 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)44 List (java.util.List)44 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)42 Path (javax.ws.rs.Path)42 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)37 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)37