Search in sources :

Example 21 with VolumeGroup

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

the class VolumeGroupService method getVolumeGroupSnapshotSessions.

/**
 * List snapshot sessions for a volume group
 *
 * @param volumeGroupId The URI of the volume group.
 * @brief List snapshot session for a volume group
 * @return BlockSnapshotSessionList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public BlockSnapshotSessionList getVolumeGroupSnapshotSessions(@PathParam("id") final URI volumeGroupId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
    // query volume group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // get the snapshot sessions for each CG in the volume group
    BlockSnapshotSessionList snapshotSessionList = new BlockSnapshotSessionList();
    // get all snapshot sessions for the volume group
    List<BlockSnapshotSession> volumeGroupSessions = getVolumeGroupSnapshotSessions(volumeGroup);
    for (BlockSnapshotSession session : volumeGroupSessions) {
        snapshotSessionList.getSnapSessionRelatedResourceList().add(toNamedRelatedResource(session));
    }
    return snapshotSessionList;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 22 with VolumeGroup

use of com.emc.storageos.db.client.model.VolumeGroup 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 23 with VolumeGroup

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

the class VolumeGroupService method detachVolumeGroupFullCopy.

/**
 * Detach the specified Volume group full copy.
 * - Detaches full copy for all the array replication groups within this Application.
 * - If partial flag is specified, it detaches full copy only for set of array replication groups.
 * A Full Copy from each array replication group can be provided to indicate which array replication
 * groups's full copies needs to be detached.
 *
 * @prereq Create Volume group full copy as active.
 *
 * @param volumeGroupId The URI of the Volume group.
 * @param fullCopyURI The URI of the full copy.
 *
 * @brief Detach Volume group full copy.
 *
 * @return TaskList
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies/detach")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList detachVolumeGroupFullCopy(@PathParam("id") final URI volumeGroupId, final VolumeGroupFullCopyDetachParam param) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, "id");
    // Query Volume Group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    TaskList taskList = new TaskList();
    // validate replica operation for volume group
    validateCopyOperationForVolumeGroup(volumeGroup, ReplicaTypeEnum.FULL_COPY);
    // validate the requested full copies
    List<Volume> fullCopyVolumesInRequest = new ArrayList<Volume>();
    boolean partial = validateFullCopiesInRequest(fullCopyVolumesInRequest, param.getFullCopies(), param.getCopySetName(), param.getSubGroups(), volumeGroupId);
    /**
     * 1. VolumeGroupService Clone API accepts a Clone URI (to identify clone set and RG)
     * - then get All full copies belonging to same full copy set
     * - get full copy set name from the requested full copy
     * 2. If partial, there will be a List of Clone URIs (one from each RG)
     * 3. Group the full copies by Replication Group(RG)
     * 4. For each RG, invoke the ConsistencyGroup full copy API (CG uri, clone uri)
     * - a. Skip the CG/RG calls when thrown error and continue with other entries; create 'ERROR' Task for this call
     * - b. Finally return the Task List (RG tasks may finish at different times as they are different calls)
     */
    if (!partial) {
        Volume fullCopy = fullCopyVolumesInRequest.get(0);
        log.info("Full Copy operation requested for entire Application, Considering full copy {} in request.", fullCopy.getLabel());
        fullCopyVolumesInRequest.clear();
        fullCopyVolumesInRequest.addAll(getClonesBySetName(fullCopy.getFullCopySetName(), volumeGroup.getId()));
    } else {
        log.info("Full Copy operation requested for subset of array replication groups in Application.");
    }
    checkForApplicationPendingTasks(volumeGroup, _dbClient, true);
    Map<String, Volume> repGroupToFullCopyMap = groupVolumesByReplicationGroup(fullCopyVolumesInRequest);
    for (Map.Entry<String, Volume> entry : repGroupToFullCopyMap.entrySet()) {
        String replicationGroup = entry.getKey();
        Volume fullCopy = entry.getValue();
        log.info("Processing Array Replication Group {}, Full Copy {}", replicationGroup, fullCopy.getLabel());
        try {
            // get CG URI
            URI cgURI = getConsistencyGroupForFullCopy(fullCopy);
            // Detach the full copy. Note that it will take into account the
            // fact that the volume is in a ReplicationGroup
            // and all volumes in that ReplicationGroup will be detached.
            taskList.getTaskList().addAll(_blockConsistencyGroupService.detachConsistencyGroupFullCopy(cgURI, fullCopy.getId()).getTaskList());
        } catch (InternalException | APIException e) {
            String errMsg = String.format("Error detaching Array Replication Group %s, Full Copy %s", replicationGroup, fullCopy.getLabel());
            log.error(errMsg, e);
            TaskResourceRep task = BlockServiceUtils.createFailedTaskOnVolume(_dbClient, fullCopy, ResourceOperationTypeEnum.DETACH_VOLUME_FULL_COPY, e);
            taskList.addTask(task);
        }
    }
    if (!partial) {
        auditOp(OperationTypeEnum.DETACH_VOLUME_GROUP_FULL_COPY, true, AuditLogManager.AUDITOP_BEGIN, volumeGroup.getId().toString(), fullCopyVolumesInRequest.get(0).getLabel());
    }
    return taskList;
}
Also used : TaskList(com.emc.storageos.model.TaskList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Map(java.util.Map) HashMap(java.util.HashMap) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 24 with VolumeGroup

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

the class VolumeGroupService method getVolumeGroupFullCopySets.

/**
 * List full copy set names for a volume group
 *
 * @param volumeGroupId The URI of the volume group.
 *
 * @brief List full copy set names for a volume group
 *
 * @return The list of full copy set names for the volume group
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public VolumeGroupCopySetList getVolumeGroupFullCopySets(@PathParam("id") final URI volumeGroupId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, "id");
    // Query Volume Group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // get all volumes
    List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
    // Cycle over the volumes in the volume group and
    // get the full copies for each volume in the group.
    VolumeGroupCopySetList fullCopySets = new VolumeGroupCopySetList();
    for (Volume volume : volumes) {
        StringSet fullCopyIds = volume.getFullCopies();
        if (fullCopyIds != null) {
            for (String fullCopyId : fullCopyIds) {
                Volume fullCopyVolume = _dbClient.queryObject(Volume.class, URI.create(fullCopyId));
                if (fullCopyVolume == null || fullCopyVolume.getInactive()) {
                    log.warn("Stale full copy {} found for volume {}", fullCopyId, volume.getLabel());
                    continue;
                }
                String setName = fullCopyVolume.getFullCopySetName();
                if (NullColumnValueGetter.isNullValue(setName)) {
                    // This should not happen
                    log.warn(String.format("skipping volume %s becuase fullCopySetName is null", fullCopyVolume.getLabel()));
                    continue;
                }
                fullCopySets.getCopySets().add(setName);
            }
        }
    }
    return fullCopySets;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) StringSet(com.emc.storageos.db.client.model.StringSet) VolumeGroupCopySetList(com.emc.storageos.model.application.VolumeGroupCopySetList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 25 with VolumeGroup

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

the class AbstractBlockFullCopyApiImpl method getTasksForCreateFullCopy.

/**
 * returns the list of tasks required for create the full copy volumes.
 *
 * @param fcSourceObj
 *            A reference to a full copy source.
 * @param fullCopyVolumes
 *            A list of the prepared full copy volumes.
 * @param taskId
 *            The unique task identifier
 *
 * @return TaskList
 */
protected TaskList getTasksForCreateFullCopy(BlockObject fcSourceObj, List<Volume> fullCopyVolumes, String taskId) {
    if (fcSourceObj == null) {
        throw APIException.badRequests.fullCopyInternalError("create");
    }
    TaskList taskList = new TaskList();
    for (Volume volume : fullCopyVolumes) {
        Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), taskId, ResourceOperationTypeEnum.CREATE_VOLUME_FULL_COPY);
        volume.getOpStatus().put(taskId, op);
        TaskResourceRep volumeTask = TaskMapper.toTask(volume, taskId, op);
        taskList.getTaskList().add(volumeTask);
    }
    // if Volume is part of Application (COPY type VolumeGroup)
    VolumeGroup volumeGroup = (fcSourceObj instanceof Volume) ? ((Volume) fcSourceObj).getApplication(_dbClient) : null;
    if (volumeGroup != null && !ControllerUtils.checkVolumeForVolumeGroupPartialRequest(_dbClient, (Volume) fcSourceObj)) {
        Operation op = _dbClient.createTaskOpStatus(VolumeGroup.class, volumeGroup.getId(), taskId, ResourceOperationTypeEnum.CREATE_VOLUME_GROUP_FULL_COPY);
        taskList.getTaskList().add(TaskMapper.toTask(volumeGroup, taskId, op));
        // get all volumes to create tasks for all CGs involved
        List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
        addConsistencyGroupTasks(volumes, taskList, taskId, ResourceOperationTypeEnum.CREATE_CONSISTENCY_GROUP_FULL_COPY);
    } else {
        addConsistencyGroupTasks(Arrays.asList(fcSourceObj), taskList, taskId, ResourceOperationTypeEnum.CREATE_CONSISTENCY_GROUP_FULL_COPY);
    }
    return taskList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) TaskList(com.emc.storageos.model.TaskList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation)

Aggregations

VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)52 Volume (com.emc.storageos.db.client.model.Volume)35 Produces (javax.ws.rs.Produces)29 Path (javax.ws.rs.Path)27 URI (java.net.URI)26 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)21 ArrayList (java.util.ArrayList)20 TaskList (com.emc.storageos.model.TaskList)15 GET (javax.ws.rs.GET)15 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)14 Consumes (javax.ws.rs.Consumes)13 POST (javax.ws.rs.POST)13 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)12 NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)10 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)9 VolumeGroupCopySetList (com.emc.storageos.model.application.VolumeGroupCopySetList)9 NamedURI (com.emc.storageos.db.client.model.NamedURI)8 SnapshotList (com.emc.storageos.model.SnapshotList)8 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)8