Search in sources :

Example 41 with BlockController

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

the class VMAXBlockFullCopyApiImpl method establishVolumeAndFullCopyGroupRelation.

/**
 * {@inheritDoc}
 */
@Override
public TaskList establishVolumeAndFullCopyGroupRelation(Volume sourceVolume, Volume fullCopyVolume) {
    // Create the task list.
    TaskList taskList = new TaskList();
    // Create a unique task id.
    String taskId = UUID.randomUUID().toString();
    // Get the id of the source volume.
    URI sourceVolumeURI = sourceVolume.getId();
    // Get the id of the full copy volume.
    URI fullCopyURI = fullCopyVolume.getId();
    // Get the storage system for the source volume.
    StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
    URI sourceSystemURI = sourceSystem.getId();
    // Create the task on the full copy volume.
    Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.ESTABLISH_VOLUME_FULL_COPY);
    fullCopyVolume.getOpStatus().put(taskId, op);
    TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyVolume, taskId, op);
    taskList.getTaskList().add(fullCopyVolumeTask);
    // Invoke the controller.
    try {
        BlockController controller = getController(BlockController.class, sourceSystem.getSystemType());
        controller.establishVolumeAndFullCopyGroupRelation(sourceSystemURI, sourceVolumeURI, fullCopyURI, taskId);
    } catch (InternalException ie) {
        s_logger.error(String.format("Failed to establish group relation between volume group" + " and full copy group. Volume: %s, Full copy: %s", sourceVolumeURI, fullCopyVolume.getId()), ie);
        super.handleFailedRequest(taskId, taskList, Arrays.asList(fullCopyVolume), ie, false);
    }
    return taskList;
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 42 with BlockController

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

the class VMAX3BlockSnapshotSessionApiImpl method relinkTargetVolumesToSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void relinkTargetVolumesToSnapshotSession(BlockObject snapSessionSourceObj, BlockSnapshotSession tgtSnapSession, List<URI> snapshotURIs, String taskId) {
    // Invoke the BlockDeviceController to relink the targets
    // to the passed target snapshot session.
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
    BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
    controller.relinkTargetsToSnapshotSession(storageSystem.getId(), tgtSnapSession.getId(), snapshotURIs, Boolean.TRUE, taskId);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 43 with BlockController

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

the class VMAX3BlockSnapshotSessionApiImpl method restoreSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void restoreSnapshotSession(BlockSnapshotSession snapSession, BlockObject snapSessionSourceObj, String taskId) {
    // Invoke the BlockDeviceController to restore the snapshot session source.
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
    BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
    controller.restoreSnapshotSession(storageSystem.getId(), snapSession.getId(), Boolean.TRUE, taskId);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 44 with BlockController

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

the class VMAX3BlockSnapshotSessionApiImpl method unlinkTargetVolumesFromSnapshotSession.

/**
 * {@inheritDoc}
 */
@Override
public void unlinkTargetVolumesFromSnapshotSession(BlockObject snapSessionSourceObj, BlockSnapshotSession snapSession, Map<URI, Boolean> snapshotDeletionMap, OperationTypeEnum opType, String taskId) {
    // Invoke the BlockDeviceController to unlink the targets
    // from the snapshot session.
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, snapSessionSourceObj.getStorageController());
    BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
    controller.unlinkTargetsFromSnapshotSession(storageSystem.getId(), snapSession.getId(), snapshotDeletionMap, opType, taskId);
}
Also used : BlockController(com.emc.storageos.volumecontroller.BlockController) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 45 with BlockController

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

the class BlockMirrorServiceApiImpl method resumeNativeContinuousCopies.

/**
 * {@inheritDoc}
 */
@Override
public TaskList resumeNativeContinuousCopies(StorageSystem storageSystem, Volume sourceVolume, List<BlockMirror> blockMirrors, String taskId) throws ControllerException {
    _log.info("START resume native continuous copies");
    TaskList taskList = new TaskList();
    List<URI> resumedMirrors = new ArrayList<URI>();
    List<URI> mirrorURIs = new ArrayList<URI>();
    Map<BlockMirror, Volume> groupMirrorSourceMap = null;
    List<BlockMirror> mirrorsToProcess = null;
    boolean isCG = sourceVolume.isInCG();
    if (isCG) {
        if (blockMirrors == null) {
            for (String uriStr : sourceVolume.getMirrors()) {
                BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, URI.create(uriStr));
                if (mirrorIsResumable(mirror)) {
                    groupMirrorSourceMap = getGroupMirrorSourceMap(mirror, sourceVolume);
                    // only process one mirror group
                    break;
                }
            }
        } else {
            groupMirrorSourceMap = getGroupMirrorSourceMap(blockMirrors.get(0), sourceVolume);
        }
        if (groupMirrorSourceMap == null || groupMirrorSourceMap.isEmpty()) {
            Operation op = new Operation();
            op.ready();
            op.setResourceType(ResourceOperationTypeEnum.RESUME_VOLUME_MIRROR);
            op.setMessage("No continuous copy can be resumed");
            _dbClient.createTaskOpStatus(Volume.class, sourceVolume.getId(), taskId, op);
            taskList.getTaskList().add(toTask(sourceVolume, taskId, op));
            return taskList;
        }
        mirrorsToProcess = new ArrayList<BlockMirror>(groupMirrorSourceMap.keySet());
        mirrorURIs = new ArrayList<URI>(transform(mirrorsToProcess, FCTN_MIRROR_TO_URI));
    } else {
        // Assume all continuous copies are to be resumed
        mirrorsToProcess = blockMirrors;
        if (mirrorsToProcess == null) {
            mirrorsToProcess = new ArrayList<BlockMirror>();
            for (String uriStr : sourceVolume.getMirrors()) {
                BlockMirror mirror = _dbClient.queryObject(BlockMirror.class, URI.create(uriStr));
                mirrorsToProcess.add(mirror);
            }
        }
        for (BlockMirror mirror : mirrorsToProcess) {
            if (mirrorIsPausable(mirror) || mirrorIsResynchronizing(mirror)) {
                // extract mirrors that are in resume state or resynchronizing
                resumedMirrors.add(mirror.getId());
            } else if (!mirrorIsResumable(mirror)) {
                throw APIException.badRequests.cannotResumeContinuousCopyWithSyncState(mirror.getId(), mirror.getSyncState(), sourceVolume.getId());
            }
            mirrorURIs.add(mirror.getId());
        }
    }
    /*
         * if all mirrors are resumed/resynchronizing, then there is no task to do.
         * Return a successful task
         */
    if (!resumedMirrors.isEmpty() && mirrorURIs.isEmpty()) {
        // If the mirrors is already resumed or resynchronizing, there would be no need to queue another request to
        // resume it again.
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.RESUME_VOLUME_MIRROR);
        op.setAssociatedResourcesField(Joiner.on(',').join(resumedMirrors));
        op.ready("The continuous copies are already resumed or resynchronizing");
        _dbClient.createTaskOpStatus(Volume.class, sourceVolume.getId(), taskId, op);
        taskList.getTaskList().add(toTask(sourceVolume, taskId, op));
    } else {
        if (!isCG) {
            Collection<String> mirrorTargetIds = Collections2.transform(mirrorsToProcess, FCTN_VOLUME_URI_TO_STR);
            String mirrorTargetCommaDelimList = Joiner.on(',').join(mirrorTargetIds);
            Operation op = _dbClient.createTaskOpStatus(Volume.class, sourceVolume.getId(), taskId, ResourceOperationTypeEnum.RESUME_VOLUME_MIRROR, mirrorTargetCommaDelimList);
            taskList.getTaskList().add(toTask(sourceVolume, mirrorsToProcess, taskId, op));
        } else {
            populateTaskList(sourceVolume, groupMirrorSourceMap, taskList, taskId, ResourceOperationTypeEnum.RESUME_VOLUME_MIRROR);
        }
        try {
            BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
            controller.resumeNativeContinuousCopies(storageSystem.getId(), mirrorURIs, taskId);
        } catch (ControllerException e) {
            String errorMsg = format("Failed to resume continuous copies for source volume %s", sourceVolume.getId());
            _log.error(errorMsg, e);
            _dbClient.error(Volume.class, sourceVolume.getId(), taskId, e);
        }
    }
    return taskList;
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) 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) 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) Volume(com.emc.storageos.db.client.model.Volume)

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