Search in sources :

Example 1 with CinderSnapshotListRestResp

use of com.emc.storageos.cinder.model.CinderSnapshotListRestResp in project coprhd-controller by CoprHD.

the class SnapshotService method getSnapshotList.

/**
 * Get the summary list of all snapshots for the given tenant
 *
 * @prereq none
 *
 * @param tenant_id
 *            the URN of the tenant
 *
 * @brief List snapshots
 * @return Snapshot list
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/detail")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public Response getSnapshotList(@PathParam("tenant_id") String openstack_tenant_id, @HeaderParam("X-Cinder-V1-Call") String isV1Call, @Context HttpHeaders header) {
    CinderSnapshotListRestResp snapshots = new CinderSnapshotListRestResp();
    URIQueryResultList uris = getSnapshotUris(openstack_tenant_id);
    if (uris != null) {
        while (uris.iterator().hasNext()) {
            URI snapshotUri = uris.iterator().next();
            BlockSnapshot snap = _dbClient.queryObject(BlockSnapshot.class, snapshotUri);
            if (snap != null && !snap.getInactive()) {
                CinderSnapshot cinder_snapshot = getSnapshotDetail(snap, isV1Call, openstack_tenant_id);
                snapshots.getSnapshots().add(cinder_snapshot);
            }
        }
    }
    return CinderApiUtils.getCinderResponse(snapshots, header, false, CinderConstants.STATUS_OK);
}
Also used : CinderSnapshot(com.emc.storageos.cinder.model.CinderSnapshot) CinderSnapshotListRestResp(com.emc.storageos.cinder.model.CinderSnapshotListRestResp) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

CinderSnapshot (com.emc.storageos.cinder.model.CinderSnapshot)1 CinderSnapshotListRestResp (com.emc.storageos.cinder.model.CinderSnapshotListRestResp)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 URI (java.net.URI)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1