Search in sources :

Example 6 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method deleteConsistencyGroup.

/**
 * {@inheritDoc}
 */
@Override
public TaskResourceRep deleteConsistencyGroup(StorageSystem device, BlockConsistencyGroup consistencyGroup, String task) throws ControllerException {
    Operation op = _dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroup.getId(), task, ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP);
    // Get VPlex controller and delete the consistency group.
    VPlexController controller = getController();
    controller.deleteConsistencyGroup(device.getId(), consistencyGroup.getId(), task);
    return toTask(consistencyGroup, task, op);
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) Operation(com.emc.storageos.db.client.model.Operation)

Example 7 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method updateVolumesInVolumeGroup.

/**
 * {@inheritDoc}
 */
@Override
public void updateVolumesInVolumeGroup(VolumeGroupVolumeList addVolumes, List<Volume> removeVolumes, URI volumeGroupId, String taskId) {
    ApplicationAddVolumeList addVols = new ApplicationAddVolumeList();
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
    URI systemURI = getVolumesToAddToApplication(addVols, addVolumes, volumeGroup, taskId);
    List<URI> removeVolIds = new ArrayList<URI>();
    URI removeSystemURI = getVolumesToRemoveFromApplication(removeVolIds, removeVolumes);
    if (systemURI == null) {
        systemURI = removeSystemURI;
    }
    if (systemURI != null) {
        VPlexController controller = getController();
        controller.updateVolumeGroup(systemURI, addVols, removeVolIds, volumeGroup.getId(), taskId);
    } else {
        // No need to call to controller. update the application task
        Operation op = volumeGroup.getOpStatus().get(taskId);
        op.ready();
        volumeGroup.getOpStatus().updateTaskStatus(taskId, op);
        _dbClient.updateObject(volumeGroup);
    }
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) ApplicationAddVolumeList(com.emc.storageos.volumecontroller.ApplicationAddVolumeList) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) ArrayList(java.util.ArrayList) 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)

Example 8 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockFullCopyApiImpl method detach.

/**
 * {@inheritDoc}
 */
@Override
public TaskList detach(BlockObject fcSourceObj, Volume fullCopyVolume) {
    // If full copy volume is already detached or was never
    // activated, return detach action is completed successfully
    // as done in base class. Otherwise, send detach full copy
    // request to controller.
    TaskList taskList = new TaskList();
    String taskId = UUID.randomUUID().toString();
    if ((BlockFullCopyUtils.isFullCopyDetached(fullCopyVolume, _dbClient)) || (BlockFullCopyUtils.isFullCopyInactive(fullCopyVolume, _dbClient))) {
        super.detach(fcSourceObj, fullCopyVolume);
    } else {
        // You cannot create a full copy of a VPLEX snapshot, so
        // the source will be a volume.
        Volume sourceVolume = (Volume) fcSourceObj;
        // If the source is in a CG, then we will detach the corresponding
        // full copies for all the volumes in the CG. Since we did not allow
        // full copies for volumes or snaps in CGs prior to Jedi, there should
        // be a full copy for all volumes in the CG.
        Map<URI, Volume> fullCopyMap = getFullCopySetMap(sourceVolume, fullCopyVolume);
        Set<URI> fullCopyURIs = fullCopyMap.keySet();
        // Get the storage system for the source volume.
        StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceVolume.getStorageController());
        URI sourceSystemURI = sourceSystem.getId();
        // Create the detach task on the full copy volumes.
        for (URI fullCopyURI : fullCopyURIs) {
            Operation op = _dbClient.createTaskOpStatus(Volume.class, fullCopyURI, taskId, ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY);
            fullCopyMap.get(fullCopyURI).getOpStatus().put(taskId, op);
            TaskResourceRep fullCopyVolumeTask = TaskMapper.toTask(fullCopyMap.get(fullCopyURI), taskId, op);
            taskList.getTaskList().add(fullCopyVolumeTask);
        }
        addConsistencyGroupTasks(Arrays.asList(sourceVolume), taskList, taskId, ResourceOperationTypeEnum.DETACH_CONSISTENCY_GROUP_FULL_COPY);
        // Invoke the controller.
        try {
            VPlexController controller = getController(VPlexController.class, DiscoveredDataObject.Type.vplex.toString());
            controller.detachFullCopy(sourceSystemURI, new ArrayList<>(fullCopyURIs), taskId);
        } catch (InternalException ie) {
            s_logger.error("Controller error: Failed to detach volume full copy {}", fullCopyVolume.getId(), ie);
            handleFailedRequest(taskId, taskList, new ArrayList<>(fullCopyMap.values()), ie, false);
        }
    }
    return taskList;
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method stopNativeContinuousCopies.

/**
 * {@inheritDoc}
 */
@Override
public TaskList stopNativeContinuousCopies(StorageSystem vplexStorageSystem, Volume sourceVolume, List<URI> mirrors, String taskId) throws ControllerException {
    TaskList taskList = new TaskList();
    List<VplexMirror> vplexMirrors = null;
    if (mirrors != null) {
        vplexMirrors = new ArrayList<VplexMirror>();
        for (URI mirrorURI : mirrors) {
            VplexMirror vplexMirror = _dbClient.queryObject(VplexMirror.class, mirrorURI);
            if (vplexMirror.getDeviceLabel() == null) {
                s_logger.error("This Vplex Mirror {} was not created successfully.", vplexMirror.getId());
                throw APIException.badRequests.invalidVplexMirror(vplexMirror.getLabel(), vplexMirror.getId().toString());
            }
            vplexMirrors.add(vplexMirror);
        }
    }
    // If mirrors is null then this will return all mirrors for the source volume.
    // This will be mostly case through python script that will just make a call
    // to stop mirrors without specifying mirror ID.
    // Note : There will be only one mirror for the vplex volume though
    List<URI> copiesToStop = getVplexCopiesToStop(vplexMirrors, sourceVolume);
    // Removes inactive mirrors
    removeIf(copiesToStop, isVplexMirrorInactivePredicate());
    String mirrorTargetCommaDelimList = Joiner.on(',').join(copiesToStop);
    Operation op = _dbClient.createTaskOpStatus(Volume.class, sourceVolume.getId(), taskId, ResourceOperationTypeEnum.DETACH_VPLEX_LOCAL_MIRROR, mirrorTargetCommaDelimList);
    List<VplexMirror> copies = _dbClient.queryObject(VplexMirror.class, copiesToStop);
    // Stopped copies will be promoted to vplex volumes.
    // Creates volume objects for the mirrors that will be promoted
    List<URI> promotees = preparePromotedVolumes(copies, taskList, taskId);
    // Add task to the task list
    taskList.getTaskList().add(toTask(sourceVolume, copies, taskId, op));
    try {
        VPlexController controller = getController();
        controller.detachContinuousCopies(vplexStorageSystem.getId(), sourceVolume.getId(), copiesToStop, promotees, taskId);
    } catch (InternalException e) {
        String errorMsg = format("Failed to stop continuous copies for volume %s: %s", sourceVolume.getId(), e.getMessage());
        for (TaskResourceRep taskResourceRep : taskList.getTaskList()) {
            taskResourceRep.setState(Operation.Status.error.name());
            taskResourceRep.setMessage(errorMsg);
            _dbClient.error(Volume.class, taskResourceRep.getResource().getId(), taskId, e);
        }
        throw e;
    }
    return taskList;
}
Also used : VPlexController(com.emc.storageos.vplexcontroller.VPlexController) Volume(com.emc.storageos.db.client.model.Volume) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) VplexMirror(com.emc.storageos.db.client.model.VplexMirror) 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) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException)

Example 10 with VPlexController

use of com.emc.storageos.vplexcontroller.VPlexController in project coprhd-controller by CoprHD.

the class VPlexBlockServiceApiImpl method expandVolume.

/**
 * {@inheritDoc}
 */
@Override
public void expandVolume(Volume vplexVolume, long newSize, String taskId) throws InternalException {
    URI vplexURI = vplexVolume.getStorageController();
    if (isNativeVolumeExpansionSupported(vplexVolume, newSize)) {
        // Expand the passed VPlex virtual volume by natively
        // expanding the backend volume(s).
        // TODO: At the moment, native expansion go via block orchestration controller. JIRA CTRL-5336 filed for this.
        // Expand via migration still follows the old way of doing things and this needs to be changed.
        s_logger.info("VPLEX volume {} will be expanded natively.", vplexVolume.getId());
        List<VolumeDescriptor> volumeDescriptors = createVolumeDescriptorsForNativeExpansion(Arrays.asList(vplexVolume.getId()));
        BlockOrchestrationController controller = getController(BlockOrchestrationController.class, BlockOrchestrationController.BLOCK_ORCHESTRATION_DEVICE);
        for (VolumeDescriptor volDesc : volumeDescriptors) {
            volDesc.setVolumeSize(newSize);
        }
        controller.expandVolume(volumeDescriptors, taskId);
    } else {
        // A list of the volumes satisfying the new size to
        // which the data on the current backend volumes
        // will be migrated.
        s_logger.info("VPLEX volume {} will be expanded by migration.", vplexVolume.getId());
        List<URI> newVolumes = new ArrayList<URI>();
        // A Map containing a migration for each new backend
        // volume
        Map<URI, URI> migrationMap = new HashMap<URI, URI>();
        // A map that specifies the storage pool in which
        // each new volume should be created.
        Map<URI, URI> poolVolumeMap = new HashMap<URI, URI>();
        // Get the VPlex system.
        StorageSystem vplexSystem = _permissionsHelper.getObjectById(vplexURI, StorageSystem.class);
        // Prepare the backend volume(s) for migration.
        StringSet assocVolumeIds = vplexVolume.getAssociatedVolumes();
        if (null == assocVolumeIds || assocVolumeIds.isEmpty()) {
            s_logger.error("VPLEX volume {} has no backend volumes.", vplexVolume.forDisplay());
            throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(vplexVolume.forDisplay());
        }
        for (String assocVolumeId : assocVolumeIds) {
            Volume assocVolume = _permissionsHelper.getObjectById(URI.create(assocVolumeId), Volume.class);
            VirtualArray assocVolumeNH = _permissionsHelper.getObjectById(assocVolume.getVirtualArray(), VirtualArray.class);
            VirtualPool assocVolumeCos = _permissionsHelper.getObjectById(assocVolume.getVirtualPool(), VirtualPool.class);
            prepareBackendVolumeForMigration(vplexSystem, vplexVolume, assocVolume, assocVolumeNH, assocVolumeCos, newSize, taskId, newVolumes, migrationMap, poolVolumeMap);
        }
        // Use the VPlex controller to expand the passed VPlex virtual
        // volume by migrating the backend volume(s) to the migration
        // target(s) of the new size.
        VPlexController controller = getController();
        controller.expandVolumeUsingMigration(vplexURI, vplexVolume.getId(), newVolumes, migrationMap, poolVolumeMap, newSize, taskId);
    }
}
Also used : VolumeDescriptor(com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor) BlockOrchestrationController(com.emc.storageos.blockorchestrationcontroller.BlockOrchestrationController) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VPlexController(com.emc.storageos.vplexcontroller.VPlexController) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) 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) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VPlexController (com.emc.storageos.vplexcontroller.VPlexController)20 Volume (com.emc.storageos.db.client.model.Volume)17 URI (java.net.URI)17 Operation (com.emc.storageos.db.client.model.Operation)16 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)13 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)11 ArrayList (java.util.ArrayList)10 NamedURI (com.emc.storageos.db.client.model.NamedURI)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)7 FCTN_VPLEX_MIRROR_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_VPLEX_MIRROR_TO_URI)7 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)6 TaskList (com.emc.storageos.model.TaskList)6 VolumeDescriptor (com.emc.storageos.blockorchestrationcontroller.VolumeDescriptor)5 Migration (com.emc.storageos.db.client.model.Migration)5 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 POST (javax.ws.rs.POST)5 Produces (javax.ws.rs.Produces)5 Project (com.emc.storageos.db.client.model.Project)4