Search in sources :

Example 16 with BlockController

use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.

the class BlockMirrorServiceApiImpl method establishVolumeAndNativeContinuousCopyGroupRelation.

/**
 * {@inheritDoc}
 */
@Override
public TaskResourceRep establishVolumeAndNativeContinuousCopyGroupRelation(StorageSystem storageSystem, Volume sourceVolume, BlockMirror blockMirror, String taskId) throws ControllerException {
    _log.info("START establish Volume and Mirror group relation");
    Operation op = _dbClient.createTaskOpStatus(Volume.class, sourceVolume.getId(), taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_MIRROR, blockMirror.getId().toString());
    try {
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.establishVolumeAndNativeContinuousCopyGroupRelation(storageSystem.getId(), sourceVolume.getId(), blockMirror.getId(), taskId);
    } catch (ControllerException e) {
        String errorMsg = format("Failed to establish group relation between volume group and mirror group." + "Source volume: %s, Mirror: %s", sourceVolume.getId(), blockMirror.getId());
        _log.error(errorMsg, e);
        _dbClient.error(Volume.class, sourceVolume.getId(), taskId, e);
    }
    return toTask(sourceVolume, Arrays.asList(blockMirror), taskId, op);
}
Also used : DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) Volume(com.emc.storageos.db.client.model.Volume) Operation(com.emc.storageos.db.client.model.Operation)

Example 17 with BlockController

use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.

the class DefaultBlockServiceApiImpl method establishVolumeAndSnapshotGroupRelation.

/**
 * {@inheritDoc}
 *
 * @throws ControllerException
 */
@Override
public TaskResourceRep establishVolumeAndSnapshotGroupRelation(StorageSystem storageSystem, Volume sourceVolume, BlockSnapshot snapshot, String taskId) throws ControllerException {
    _log.info("START establish Volume and Snapshot group relation");
    // Create the task on the block snapshot
    Operation op = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_SNAPSHOT);
    snapshot.getOpStatus().put(taskId, op);
    try {
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.establishVolumeAndSnapshotGroupRelation(storageSystem.getId(), sourceVolume.getId(), snapshot.getId(), taskId);
    } catch (ControllerException e) {
        String errorMsg = String.format("Failed to establish group relation between volume group and snapshot group." + "Source volume: %s, Snapshot: %s", sourceVolume.getId(), snapshot.getId());
        _log.error(errorMsg, e);
        _dbClient.error(BlockSnapshot.class, snapshot.getId(), taskId, e);
    }
    return toTask(snapshot, taskId, op);
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Operation(com.emc.storageos.db.client.model.Operation)

Example 18 with BlockController

use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method updateConsistencyGroup.

/**
 * {@inheritDoc}
 */
@Override
public TaskResourceRep updateConsistencyGroup(StorageSystem cgStorageSystem, List<Volume> cgVolumes, BlockConsistencyGroup consistencyGroup, List<URI> addVolumesList, List<URI> removeVolumesList, String taskId) throws ControllerException {
    // addVolumesList could be volumes, or full copies, or snapshots or mirrors.
    List<URI> addVolumes = new ArrayList<URI>();
    List<URI> addSnapshots = new ArrayList<URI>();
    List<URI> addFullcopies = new ArrayList<URI>();
    for (URI volumeURI : addVolumesList) {
        BlockObject blockObject = BlockObject.fetch(_dbClient, volumeURI);
        if (blockObject instanceof BlockMirror) {
            throw APIException.badRequests.actionNotApplicableForVplexVolumeMirrors(ResourceOperationTypeEnum.UPDATE_CONSISTENCY_GROUP.name());
        } else if (blockObject instanceof BlockSnapshot) {
            addSnapshots.add(volumeURI);
        } else if (blockObject instanceof Volume) {
            boolean isFullCopy = ControllerUtils.isVolumeFullCopy((Volume) blockObject, _dbClient);
            if (isFullCopy) {
                addFullcopies.add(volumeURI);
            } else {
                addVolumes.add(volumeURI);
            }
        }
    }
    if ((!addVolumes.isEmpty() && (!addSnapshots.isEmpty() || !addFullcopies.isEmpty())) || (!addSnapshots.isEmpty() && !addFullcopies.isEmpty())) {
        throw APIException.badRequests.cantUpdateCGWithMixedBlockObjects(consistencyGroup.getLabel());
    }
    // group.
    if (!addVolumes.isEmpty()) {
        Iterator<Volume> cgVolumesIter = cgVolumes.iterator();
        if (cgVolumesIter.hasNext()) {
            Volume cgVolume = cgVolumesIter.next();
            VirtualPool cgVPool = _permissionsHelper.getObjectById(cgVolume.getVirtualPool(), VirtualPool.class);
            URI cgVArrayURI = cgVolume.getVirtualArray();
            String cgHAType = cgVPool.getHighAvailability();
            for (URI volumeURI : addVolumes) {
                Volume addVolume = _permissionsHelper.getObjectById(volumeURI, Volume.class);
                VirtualPool addVolumeVPool = _permissionsHelper.getObjectById(addVolume.getVirtualPool(), VirtualPool.class);
                if (!addVolumeVPool.getHighAvailability().equals(cgHAType)) {
                    throw APIException.badRequests.invalidParameterConsistencyGroupVolumeHasIncorrectHighAvailability(cgVolume.getId(), cgHAType);
                } else if (!cgVArrayURI.equals(addVolume.getVirtualArray())) {
                    throw APIException.badRequests.invalidParameterConsistencyGroupVolumeHasIncorrectVArray(cgVolume.getId(), cgVArrayURI);
                }
            }
        }
        // Check if the volumes have been in the CG, and not ingestion case
        if (consistencyGroup.getTypes().contains(Types.LOCAL.toString()) && !cgVolumes.isEmpty()) {
            Set<String> cgVolumesURISet = new HashSet<String>();
            for (Volume cgVolume : cgVolumes) {
                cgVolumesURISet.add(cgVolume.getId().toString());
            }
            Iterator<URI> iter = addVolumes.iterator();
            while (iter.hasNext()) {
                if (cgVolumesURISet.contains(iter.next().toString())) {
                    iter.remove();
                }
            }
            if (addVolumes.isEmpty()) {
                // All volumes in the addVolumes list have been in the CG. return success
                s_logger.info("The volumes have been added to the CG");
                Operation op = new Operation();
                op.setResourceType(ResourceOperationTypeEnum.UPDATE_CONSISTENCY_GROUP);
                op.ready("Volumes have been added to the consistency group");
                _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroup.getId(), taskId, op);
                return toTask(consistencyGroup, taskId, op);
            }
        }
    }
    // Only add snapshot or full copies to CG if backend volumes are from the same storage system.
    if (!addSnapshots.isEmpty() || !addFullcopies.isEmpty()) {
        if (!VPlexUtil.isVPLEXCGBackendVolumesInSameStorage(cgVolumes, _dbClient)) {
            throw APIException.badRequests.cantUpdateCGWithReplicaFromMultipleSystems(consistencyGroup.getLabel());
        }
    }
    Operation op = _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroup.getId(), taskId, ResourceOperationTypeEnum.UPDATE_CONSISTENCY_GROUP);
    // When adding snapshots to CG, just call block implementation.
    if (!addSnapshots.isEmpty()) {
        BlockSnapshot snapshot = _permissionsHelper.getObjectById(addSnapshots.get(0), BlockSnapshot.class);
        URI systemURI = snapshot.getStorageController();
        StorageSystem system = _permissionsHelper.getObjectById(systemURI, StorageSystem.class);
        BlockController controller = getController(BlockController.class, system.getSystemType());
        controller.updateConsistencyGroup(system.getId(), consistencyGroup.getId(), addVolumesList, removeVolumesList, taskId);
        return toTask(consistencyGroup, taskId, op);
    }
    // all the virtual volumes in the CG have to be selected.
    if (!addVolumes.isEmpty()) {
        verifyAddVolumesToIngestedCG(consistencyGroup, addVolumes);
    }
    if (!addFullcopies.isEmpty()) {
        addVolumes.addAll(addFullcopies);
    }
    // Get VPlex controller
    VPlexController controller = getController();
    controller.updateConsistencyGroup(cgStorageSystem.getId(), consistencyGroup.getId(), addVolumes, removeVolumesList, taskId);
    return toTask(consistencyGroup, taskId, op);
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) VPlexController(com.emc.storageos.vplexcontroller.VPlexController) BlockController(com.emc.storageos.volumecontroller.BlockController) ArrayList(java.util.ArrayList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_VPLEX_MIRROR_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI) Volume(com.emc.storageos.db.client.model.Volume) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with BlockController

use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.

the class VMAX3BlockSnapshotSessionApiImpl method linkNewTargetVolumesToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void linkNewTargetVolumesToSnapshotSession(BlockObject snapSessionSourceObj, BlockSnapshotSession snapSession, List<List<URI>> snapshotURIs, String copyMode, String taskId) {
    // Invoke the BlockDeviceController to create and link new target
    // volumes to the passed snapshot session.
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
    BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
    controller.linkNewTargetVolumesToSnapshotSession(storageSystem.getId(), snapSession.getId(), snapshotURIs, copyMode, taskId);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 20 with BlockController

use of com.emc.storageos.volumecontroller.BlockController in project coprhd-controller by CoprHD.

the class VMAX3BlockSnapshotSessionApiImpl method deleteSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void deleteSnapshotSession(BlockSnapshotSession snapSession, BlockObject snapSessionSourceObj, String taskId, String deleteType) {
    if (VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(deleteType)) {
        // Update the task status for the session.
        // Note that we must get the session form the database to get the latest status map.
        BlockSnapshotSession updatedSession = _dbClient.queryObject(BlockSnapshotSession.class, snapSession.getId());
        Operation op = updatedSession.getOpStatus().get(taskId);
        op.ready("Snapshot session succesfully deleted from ViPR");
        updatedSession.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.updateObject(updatedSession);
        // Mark the snapshot session for deletion.
        _dbClient.markForDeletion(updatedSession);
    } else {
        // Invoke the BlockDeviceController to delete the snapshot session.
        StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
        BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
        controller.deleteSnapshotSession(storageSystem.getId(), snapSession.getId(), taskId);
    }
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockController(com.emc.storageos.volumecontroller.BlockController) Operation(com.emc.storageos.db.client.model.Operation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

BlockController (com.emc.storageos.volumecontroller.BlockController)48 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 Operation (com.emc.storageos.db.client.model.Operation)23 URI (java.net.URI)23 ArrayList (java.util.ArrayList)20 TaskList (com.emc.storageos.model.TaskList)16 Produces (javax.ws.rs.Produces)15 Volume (com.emc.storageos.db.client.model.Volume)13 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)13 Path (javax.ws.rs.Path)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 Consumes (javax.ws.rs.Consumes)12 POST (javax.ws.rs.POST)11 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)10 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)9 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 StorageProvider (com.emc.storageos.db.client.model.StorageProvider)8 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)8 Controller (com.emc.storageos.Controller)7 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)7