Search in sources :

Example 41 with VolumeGroup

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

the class VolumeGroupService method getVolumeGroup.

/**
 * List a volume group
 *
 * @param id volume group Id
 * @brief Show details for a volume group
 * @return ApplicationRestRep
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public VolumeGroupRestRep getVolumeGroup(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = (VolumeGroup) queryResource(id);
    StorageOSUser user = getUserFromContext();
    if (!_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN)) {
        // Check if the application tenant is the same as the user tenant
        List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
        if (volumes != null && !volumes.isEmpty()) {
            URI tenant = URI.create(user.getTenantId());
            Volume firstVol = volumes.get(0);
            URI volTenant = firstVol.getTenant().getURI();
            if (!volTenant.equals(tenant)) {
                APIException.forbidden.insufficientPermissionsForUser(user.getName());
            }
        }
    }
    VolumeGroupRestRep resp = DbObjectMapper.map(volumeGroup);
    resp.setReplicationGroupNames(CopyVolumeGroupUtils.getReplicationGroupNames(volumeGroup, _dbClient));
    resp.setVirtualArrays(CopyVolumeGroupUtils.getVirtualArrays(volumeGroup, _dbClient));
    return resp;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) StorageOSUser(com.emc.storageos.security.authentication.StorageOSUser) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 42 with VolumeGroup

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

the class VolumeGroupService method validateSnapshotOperation.

/**
 * Validates a snapshot operation and throws and exception if the operation cannot be done:
 *      - checks for pending tasks
 *      - for deactivate snapshot, check for any exported snapshots
 *
 * @param volumeGroupId
 * @param snapsetToSnapshots
 * @param opType
 */
private void validateSnapshotOperation(URI volumeGroupId, Map<String, List<BlockSnapshot>> snapsetToSnapshots, OperationTypeEnum opType) {
    // Check for pending tasks
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
    if (opType == OperationTypeEnum.RESTORE_VOLUME_GROUP_SNAPSHOT) {
        checkForApplicationPendingTasks(volumeGroup, _dbClient, true);
    } else {
        checkForApplicationPendingTasks(volumeGroup, _dbClient, false);
        if (opType == OperationTypeEnum.DEACTIVATE_VOLUME_GROUP_SNAPSHOT) {
            for (Entry<String, List<BlockSnapshot>> entry : snapsetToSnapshots.entrySet()) {
                String snapsetName = entry.getKey();
                List<BlockSnapshot> snapshotList = entry.getValue();
                for (BlockSnapshot snapshot : snapshotList) {
                    if (snapshot.isSnapshotExported(_dbClient)) {
                        throw APIException.badRequests.cannotDeleteApplicationSnapshotExportExists(volumeGroup.getLabel(), snapsetName);
                    }
                }
            }
        }
    }
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) NamedVolumeGroupsList(com.emc.storageos.model.block.NamedVolumeGroupsList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ClusterList(com.emc.storageos.model.host.cluster.ClusterList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeGroupCopySetList(com.emc.storageos.model.application.VolumeGroupCopySetList) SnapshotList(com.emc.storageos.model.SnapshotList)

Example 43 with VolumeGroup

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

the class VolumeGroupService method getChildrenVolumeGroups.

/**
 * Get the list of child volume groups
 *
 * @param id
 * @brief List the child volume groups
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/volume-groups")
public NamedVolumeGroupsList getChildrenVolumeGroups(@PathParam("id") URI id) {
    ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
    NamedVolumeGroupsList result = new NamedVolumeGroupsList();
    List<VolumeGroup> volumeGroups = getVolumeGroupChildren(_dbClient, volumeGroup);
    for (VolumeGroup group : volumeGroups) {
        result.getVolumeGroups().add(toNamedRelatedResource(group));
    }
    return result;
}
Also used : NamedVolumeGroupsList(com.emc.storageos.model.block.NamedVolumeGroupsList) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 44 with VolumeGroup

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

the class VolumeGroupService method getVolumeGroupSnapsetSessionSets.

/**
 * Get all snapshot session set names for a volume group.
 *
 * @param volumeGroupId The URI of the volume group
 *
 * @brief List snapset labels for a volume group
 *
 * @return VolumeGroupCopySetList
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public VolumeGroupCopySetList getVolumeGroupSnapsetSessionSets(@PathParam("id") final URI volumeGroupId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
    // query volume group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    return getVolumeGroupSnapsetSessionSets(volumeGroup);
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 45 with VolumeGroup

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

the class VolumeGroupService method exposeVolumeGroupSnapshotAsVolume.

/**
 * Exposes the target volumes associated with application BlockSnapshot instances
 * as ViPR Volumes. The BlockSnapshot instances must represent snapshots
 * whose parent volumes are the backend volumes for VPLEX volumes. That is, it must be a
 * VPLEX snapshot. The purpose is to expose the backend snapshot as a VPLEX volume so
 * that access to the snapshot is via the VPLEX rather than directly via the backend
 * storage system.
 *
 * The volumes created are not added to the application
 *
 * @prereq Create volume group snapshot
 *
 * @param volumeGroupId The URI of the volume group
 * @param param VolumeGroupSnapshotOperationParam
 *
 * @brief Expose application snapshots as vplex volumes
 *
 * @return TaskList
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/expose")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList exposeVolumeGroupSnapshotAsVolume(@PathParam("id") final URI volumeGroupId, final VolumeGroupSnapshotOperationParam param) {
    Map<String, List<BlockSnapshot>> snapsetToSnapshots = getSnapshotsGroupedBySnapset(volumeGroupId, param);
    // Check for pending tasks
    VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
    checkForApplicationPendingTasks(volumeGroup, _dbClient, false);
    TaskList taskList = new TaskList();
    for (List<BlockSnapshot> snapshots : snapsetToSnapshots.values()) {
        for (BlockSnapshot snapshot : snapshots) {
            taskList.addTask(_blockSnapshotService.exposeSnapshotAsVolume(snapshot.getId()));
        }
    }
    return taskList;
}
Also used : VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) TaskList(com.emc.storageos.model.TaskList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) NamedVolumeGroupsList(com.emc.storageos.model.block.NamedVolumeGroupsList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ClusterList(com.emc.storageos.model.host.cluster.ClusterList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeGroupCopySetList(com.emc.storageos.model.application.VolumeGroupCopySetList) SnapshotList(com.emc.storageos.model.SnapshotList) 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)

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