Search in sources :

Example 36 with VirtualPool

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

the class AbstractBlockServiceApiImpl method checkCommonVpoolUpdates.

/**
 * Checks for Vpool updates that can be done on any device type.
 * For now, this is just the Export Path Params or Auto-tiering policy change.
 * If the update was processed, return true, else false.
 *
 * @param volumes
 * @param newVirtualPool
 * @param taskId
 * @return true if update processed
 * @throws InternalException
 */
protected boolean checkCommonVpoolUpdates(List<Volume> volumes, VirtualPool newVirtualPool, String taskId) throws InternalException {
    VirtualPool volumeVirtualPool = _dbClient.queryObject(VirtualPool.class, volumes.get(0).getVirtualPool());
    StringBuffer notSuppReasonBuff = new StringBuffer();
    if (VirtualPoolChangeAnalyzer.isSupportedPathParamsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
        BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
        for (Volume volume : volumes) {
            exportController.updateVolumePathParams(volume.getId(), newVirtualPool.getId(), taskId);
        }
        return true;
    }
    if (VirtualPoolChangeAnalyzer.isSupportedAutoTieringPolicyAndLimitsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
        /**
         * If it is a Auto-tiering policy change, it is sufficient to check on one volume in the list.
         * Mixed type volumes case has already been taken care in BlockService API.
         */
        BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
        List<URI> volumeURIs = new ArrayList<URI>();
        for (Volume volume : volumes) {
            volumeURIs.add(volume.getId());
        }
        exportController.updatePolicyAndLimits(volumeURIs, newVirtualPool.getId(), taskId);
        return true;
    }
    return false;
}
Also used : BlockExportController(com.emc.storageos.volumecontroller.BlockExportController) Volume(com.emc.storageos.db.client.model.Volume) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 37 with VirtualPool

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

the class AbstractBlockServiceApiImpl method verifyAddVolumeToCG.

/**
 * {@inheritDoc}
 */
@Override
public void verifyAddVolumeToCG(Volume volume, BlockConsistencyGroup cg, List<Volume> cgVolumes, StorageSystem cgStorageSystem) {
    // Verify that the Virtual Pool for the volume specifies
    // consistency.
    URI volumeURI = volume.getId();
    VirtualPool vPool = _permissionsHelper.getObjectById(volume.getVirtualPool(), VirtualPool.class);
    if (vPool.getMultivolumeConsistency() == null || !vPool.getMultivolumeConsistency()) {
        throw APIException.badRequests.invalidParameterConsistencyGroupVirtualPoolMustSpecifyMultiVolumeConsistency(volumeURI);
    }
    // Validate the volume is not in any other CG.
    if (!NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && !cg.getId().equals(volume.getConsistencyGroup())) {
        throw APIException.badRequests.invalidParameterVolumeAlreadyInAConsistencyGroup(cg.getId(), volume.getConsistencyGroup());
    }
    // Verify the project for the volumes to be added is the same
    // as the project for the consistency group.
    BlockConsistencyGroupUtils.verifyProjectForVolumeToBeAddedToCG(volume, cg, _dbClient);
    // Verify that the volume is on the storage system for
    // the consistency group.
    verifySystemForVolumeToBeAddedToCG(volume, cg, cgStorageSystem);
    // Don't allow partially ingested volume to be added to CG.
    BlockServiceUtils.validateNotAnInternalBlockObject(volume, false);
}
Also used : VirtualPool(com.emc.storageos.db.client.model.VirtualPool) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 38 with VirtualPool

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

the class AbstractBlockServiceApiImpl method getTaskAssociatedResources.

/**
 * Determines if there are any associated resources that are indirectly affected by this volume operation. If
 * there are we should add them to the Task object.
 *
 * @param volume
 *            The volume the operation is being performed on
 * @param vpool
 *            The vpool needed for extra information on whether to add associated resources
 * @return A list of any associated resources, null otherwise
 */
protected List<? extends DataObject> getTaskAssociatedResources(Volume volume, VirtualPool vpool) {
    List<? extends DataObject> associatedResources = null;
    VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
    // change has been made.
    if (VirtualPool.vPoolSpecifiesProtection(currentVpool) && VirtualPool.vPoolSpecifiesProtection(vpool) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
        // Get all RP Source volumes in the CG
        List<Volume> allRPSourceVolumesInCG = RPHelper.getCgSourceVolumes(volume.getConsistencyGroup(), _dbClient);
        // Remove the volume in question from the associated list, don't want a double entry because the
        // volume passed in will already be counted as an associated resource for the Task.
        allRPSourceVolumesInCG.remove(volume.getId());
        if (VirtualPool.vPoolSpecifiesRPVPlex(currentVpool) && !VirtualPool.vPoolSpecifiesMetroPoint(currentVpool) && VirtualPool.vPoolSpecifiesMetroPoint(vpool)) {
            // For an upgrade to MetroPoint (moving from RP+VPLEX vpool to MetroPoint vpool), even though the user
            // would have chosen 1 volume to update but we need to update ALL the RSets/volumes in the CG.
            // We can't just update one RSet/volume.
            s_logger.info("VirtualPool change for to upgrade to MetroPoint.");
            return allRPSourceVolumesInCG;
        }
        // Determine if the copy mode setting has changed. For this type of change, all source volumes
        // in the consistency group are affected.
        String currentCopyMode = NullColumnValueGetter.isNullValue(currentVpool.getRpCopyMode()) ? "" : currentVpool.getRpCopyMode();
        String newCopyMode = NullColumnValueGetter.isNullValue(vpool.getRpCopyMode()) ? "" : vpool.getRpCopyMode();
        if (!newCopyMode.equals(currentCopyMode)) {
            // The copy mode setting has changed.
            s_logger.info(String.format("VirtualPool change to update copy from %s to %s.", currentCopyMode, newCopyMode));
            return allRPSourceVolumesInCG;
        }
    }
    return associatedResources;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VirtualPool(com.emc.storageos.db.client.model.VirtualPool)

Example 39 with VirtualPool

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

the class BlockMirrorServiceApiImpl method startNativeContinuousCopies.

@Override
public TaskList startNativeContinuousCopies(StorageSystem storageSystem, Volume sourceVolume, VirtualPool sourceVirtualPool, VirtualPoolCapabilityValuesWrapper capabilities, NativeContinuousCopyCreate param, String taskId) throws ControllerException {
    if (!((storageSystem.getUsingSmis80() && storageSystem.deviceIsType(Type.vmax)) || storageSystem.deviceIsType(Type.vnxblock))) {
        validateNotAConsistencyGroupVolume(sourceVolume, sourceVirtualPool);
    }
    TaskList taskList = new TaskList();
    // Currently, this will create a single mirror and add it to the source volume
    // Two steps: first place the mirror and then prepare the mirror.
    List<Recommendation> volumeRecommendations = new ArrayList<Recommendation>();
    // Prepare mirror.
    int volumeCounter = 1;
    int volumeCount = capabilities.getResourceCount();
    String volumeLabel = param.getName();
    List<Volume> preparedVolumes = new ArrayList<Volume>();
    // If the requested volume is part of CG
    if (sourceVolume.isInCG()) {
        if (volumeCount > 1) {
            throw APIException.badRequests.invalidMirrorCountForVolumesInConsistencyGroup();
        }
        URIQueryResultList cgVolumeList = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumesByConsistencyGroup(sourceVolume.getConsistencyGroup()), cgVolumeList);
        // recommendation
        while (cgVolumeList.iterator().hasNext()) {
            Volume cgSourceVolume = _dbClient.queryObject(Volume.class, cgVolumeList.iterator().next());
            _log.info("Processing volume {} in CG {}", cgSourceVolume.getId(), sourceVolume.getConsistencyGroup());
            VirtualPool cgVolumeVPool = _dbClient.queryObject(VirtualPool.class, cgSourceVolume.getVirtualPool());
            populateVolumeRecommendations(capabilities, cgVolumeVPool, cgSourceVolume, taskId, taskList, volumeCount, volumeCounter, volumeLabel, preparedVolumes, volumeRecommendations);
        }
    } else {
        // Source Volume without CG
        populateVolumeRecommendations(capabilities, sourceVirtualPool, sourceVolume, taskId, taskList, volumeCount, volumeCounter, volumeLabel, preparedVolumes, volumeRecommendations);
    }
    List<URI> mirrorList = new ArrayList<URI>(preparedVolumes.size());
    for (Volume volume : preparedVolumes) {
        Operation op = _dbClient.createTaskOpStatus(BlockMirror.class, volume.getId(), taskId, ResourceOperationTypeEnum.ATTACH_BLOCK_MIRROR);
        volume.getOpStatus().put(taskId, op);
        TaskResourceRep volumeTask = toTask(volume, taskId, op);
        taskList.getTaskList().add(volumeTask);
        mirrorList.add(volume.getId());
    }
    BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
    try {
        controller.attachNativeContinuousCopies(storageSystem.getId(), sourceVolume.getId(), mirrorList, taskId);
    } catch (ControllerException ce) {
        String errorMsg = format("Failed to start continuous copies on volume %s: %s", sourceVolume.getId(), ce.getMessage());
        _log.error(errorMsg, ce);
        for (TaskResourceRep taskResourceRep : taskList.getTaskList()) {
            taskResourceRep.setState(Operation.Status.error.name());
            taskResourceRep.setMessage(errorMsg);
            Operation statusUpdate = new Operation(Operation.Status.error.name(), errorMsg);
            _dbClient.updateTaskOpStatus(Volume.class, taskResourceRep.getResource().getId(), taskId, statusUpdate);
        }
        throw ce;
    }
    return taskList;
}
Also used : DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) 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) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) VolumeRecommendation(com.emc.storageos.api.service.impl.placement.VolumeRecommendation) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Volume(com.emc.storageos.db.client.model.Volume)

Example 40 with VirtualPool

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

the class BlockService method validateVpoolCopyModeSetting.

private void validateVpoolCopyModeSetting(Volume srcVolume, String newCopyMode) {
    if (srcVolume != null) {
        URI virtualPoolURI = srcVolume.getVirtualPool();
        VirtualPool virtualPool = _dbClient.queryObject(VirtualPool.class, virtualPoolURI);
        if (virtualPool != null) {
            StringMap remoteCopySettingsMap = virtualPool.getProtectionRemoteCopySettings();
            if (remoteCopySettingsMap != null) {
                for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : VirtualPool.getRemoteProtectionSettings(virtualPool, _dbClient).entrySet()) {
                    VpoolRemoteCopyProtectionSettings copySetting = entry.getValue();
                    if (!newCopyMode.equalsIgnoreCase(copySetting.getCopyMode())) {
                        throw APIException.badRequests.invalidCopyModeOp(newCopyMode, copySetting.getCopyMode());
                    }
                }
            }
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap)

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