Search in sources :

Example 6 with VolumeGroup

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

the class VolumeGroupService method getVolumeGroupFullCopies.

/**
 * List full copies for a volume group
 *
 * @prereq none
 *
 * @param volumeGroupId The URI of the volume group.
 *
 * @brief List full copies for a volume group
 *
 * @return The list of full copies for the volume group
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public NamedVolumesList getVolumeGroupFullCopies(@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.
    NamedVolumesList fullCopyList = new NamedVolumesList();
    for (Volume volume : volumes) {
        NamedVolumesList volumeFullCopies = getFullCopyManager().getFullCopiesForSource(volume.getId());
        fullCopyList.getVolumes().addAll(volumeFullCopies.getVolumes());
    }
    return fullCopyList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 7 with VolumeGroup

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

the class VolumeGroupService method deactivateVolumeGroup.

/**
 * Delete the volume group.
 * When a volume group is deleted it will move to a "marked for deletion" state.
 *
 * @param id the URN of the volume group
 * @brief Deactivate application
 * @return No data returned in response body
 */
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public Response deactivateVolumeGroup(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = (VolumeGroup) queryResource(id);
    if (!ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup).isEmpty()) {
        // application could not be deleted if it has volumes
        throw APIException.badRequests.volumeGroupWithVolumesCantBeDeleted(volumeGroup.getLabel());
    }
    if (!getVolumeGroupHosts(_dbClient, volumeGroup).isEmpty()) {
        // application could not be deleted if it has hosts
        throw APIException.badRequests.volumeGroupWithHostsCantBeDeleted(volumeGroup.getLabel());
    }
    if (!getVolumeGroupClusters(_dbClient, volumeGroup).isEmpty()) {
        // application could not be deleted if it has clusters
        throw APIException.badRequests.volumeGroupWithClustersCantBeDeleted(volumeGroup.getLabel());
    }
    if (!getVolumeGroupChildren(_dbClient, volumeGroup).isEmpty()) {
        // application could not be deleted if it has child volume groups
        throw APIException.badRequests.volumeGroupWithChildrenCantBeDeleted(volumeGroup.getLabel());
    }
    // check for any other references to this volume group
    ArgValidator.checkReference(VolumeGroup.class, id, checkForDelete(volumeGroup));
    _dbClient.markForDeletion(volumeGroup);
    auditOp(OperationTypeEnum.DELETE_CONFIG, true, null, id.toString(), volumeGroup.getLabel());
    return Response.ok().build();
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with VolumeGroup

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

the class VolumeGroupService method getHosts.

/**
 * Get application hosts
 *
 * @param id Application Id
 * @brief List hosts for an application
 * @return HostList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/hosts")
public HostList getHosts(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
    HostList result = new HostList();
    List<Host> hosts = getVolumeGroupHosts(_dbClient, volumeGroup);
    for (Host host : hosts) {
        result.getHosts().add(toNamedRelatedResource(host));
    }
    return result;
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) HostList(com.emc.storageos.model.host.HostList) Host(com.emc.storageos.db.client.model.Host) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 9 with VolumeGroup

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

the class VolumeGroupService method restoreVolumeGroupFullCopy.

/**
 * Restore the specified Volume group full copy.
 * - Restores full copy for all the array replication groups within this Application.
 * - If partial flag is specified, it restores 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 restored.
 *
 * @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 Restore 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/restore")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList restoreVolumeGroupFullCopy(@PathParam("id") final URI volumeGroupId, final VolumeGroupFullCopyRestoreParam 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);
            // Restore 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 restored.
            taskList.getTaskList().addAll(_blockConsistencyGroupService.restoreConsistencyGroupFullCopy(cgURI, fullCopy.getId()).getTaskList());
        } catch (InternalException | APIException e) {
            String errMsg = String.format("Error restoring Array Replication Group %s, Full Copy %s", replicationGroup, fullCopy.getLabel());
            log.error(errMsg, e);
            TaskResourceRep task = BlockServiceUtils.createFailedTaskOnVolume(_dbClient, fullCopy, ResourceOperationTypeEnum.RESTORE_VOLUME_FULL_COPY, e);
            taskList.addTask(task);
        }
    }
    if (!partial) {
        auditOp(OperationTypeEnum.RESTORE_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 10 with VolumeGroup

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

the class VolumeGroupService method queryResource.

@Override
protected DataObject queryResource(URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = _permissionsHelper.getObjectById(id, VolumeGroup.class);
    ArgValidator.checkEntityNotNull(volumeGroup, id, isIdEmbeddedInURL(id));
    return volumeGroup;
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup)

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