Search in sources :

Example 6 with SoamId

use of org.onosproject.incubator.net.l2monitoring.soam.SoamId in project onos by opennetworkinglab.

the class LmWebResource method getLm.

/**
 * Get LM by MD name, MA name, Mep Id and Dm id.
 *
 * @param mdName The name of a Maintenance Domain
 * @param maName The name of a Maintenance Association belonging to the MD
 * @param mepId The Id of the MEP
 * @param lmId The Id of the LM
 * @return 200 OK with details of the LM or 500 on error
 */
@GET
@Path("{lm_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getLm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, @PathParam("lm_id") int lmId) {
    log.debug("GET called for LM {}", mdName + "/" + maName + "/" + mepId + "/" + lmId);
    try {
        MdId mdId = MdIdCharStr.asMdId(mdName);
        MaIdShort maId = MaIdCharStr.asMaId(maName);
        MepId mepIdObj = MepId.valueOf(mepId);
        SoamId lmIdObj = SoamId.valueOf(lmId);
        LossMeasurementEntry lm = get(SoamService.class).getLm(mdId, maId, mepIdObj, lmIdObj);
        if (lm == null) {
            return Response.serverError().entity("{ \"failure\":\"LM " + mdName + "/" + maName + "/" + mepId + "/" + lmId + " not found\" }").build();
        }
        ObjectNode node = mapper().createObjectNode();
        node.set("lm", codec(LossMeasurementEntry.class).encode(lm, this));
        return ok(node).build();
    } catch (CfmConfigException | SoamConfigException e) {
        log.error("Get LM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId + "/" + lmId, e.toString());
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) SoamConfigException(org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) LossMeasurementEntry(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementEntry) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Example 7 with SoamId

use of org.onosproject.incubator.net.l2monitoring.soam.SoamId in project onos by opennetworkinglab.

the class DmWebResource method abortDm.

/**
 * Abort DM by MD name, MA name, Mep Id and DM Id.
 * In the API the measurement is aborted, and not truly deleted. It still
 * remains so that its results may be read. Depending on the device it will
 * get overwritten on the creation of subsequent measurements.
 * Use clear stats to delete old results
 * measurements.
 *
 * @param mdName The name of a Maintenance Domain
 * @param maName The name of a Maintenance Association belonging to the MD
 * @param mepId The Id of the MEP
 * @param dmId The Id of the DM
 * @return 200 OK or 304 if not found, or 500 on error
 */
@DELETE
@Path("{dm_id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response abortDm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, @PathParam("dm_id") int dmId) {
    log.debug("DELETE called for DM {}", mdName + "/" + maName + "/" + mepId + "/" + dmId);
    try {
        MdId mdId = MdIdCharStr.asMdId(mdName);
        MaIdShort maId = MaIdCharStr.asMaId(maName);
        MepId mepIdObj = MepId.valueOf(mepId);
        SoamId dmIdObj = SoamId.valueOf(dmId);
        get(SoamService.class).abortDm(mdId, maId, mepIdObj, dmIdObj);
        return ok("{ \"success\":\"deleted (aborted) " + mdName + "/" + maName + "/" + mepId + "/" + dmId + "\" }").build();
    } catch (CfmConfigException e) {
        log.error("Delete (abort) DM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId + "/" + dmId, e.toString());
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 8 with SoamId

use of org.onosproject.incubator.net.l2monitoring.soam.SoamId in project onos by opennetworkinglab.

the class LmWebResource method clearLmHistory.

/**
 * Clear LM history stats by MD name, MA name, Mep Id and LM Id.
 *
 * @param mdName The name of a Maintenance Domain
 * @param maName The name of a Maintenance Association belonging to the MD
 * @param mepId The Id of the MEP
 * @param lmId The Id of the LM
 * @return 200 OK or 304 if not found, or 500 on error
 */
@PUT
@Path("{lm_id}/clear-history")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response clearLmHistory(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, @PathParam("lm_id") int lmId) {
    log.debug("clear-history called for LM {}", mdName + "/" + maName + "/" + mepId + "/" + lmId);
    try {
        MdId mdId = MdIdCharStr.asMdId(mdName);
        MaIdShort maId = MaIdCharStr.asMaId(maName);
        MepId mepIdObj = MepId.valueOf(mepId);
        SoamId lmIdObj = SoamId.valueOf(lmId);
        get(SoamService.class).clearDelayHistoryStats(mdId, maId, mepIdObj, lmIdObj);
        return ok("{ \"success\":\"cleared LM history stats for " + mdName + "/" + maName + "/" + mepId + "/" + lmId + "\" }").build();
    } catch (CfmConfigException e) {
        log.error("Clear history stats for LM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId + "/" + lmId, e.toString());
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 9 with SoamId

use of org.onosproject.incubator.net.l2monitoring.soam.SoamId in project onos by opennetworkinglab.

the class LmWebResource method abortLm.

/**
 * Abort LM by MD name, MA name, Mep Id and LM Id.
 * In the API the measurement is aborted, and not truly deleted. It still
 * remains so that its results may be read. Depending on the device it will
 * get overwritten on the creation of subsequent measurements.
 * Use clear stats to delete old results measurements.
 *
 * @param mdName The name of a Maintenance Domain
 * @param maName The name of a Maintenance Association belonging to the MD
 * @param mepId The Id of the MEP
 * @param lmId The Id of the LM
 * @return 200 OK or 304 if not found, or 500 on error
 */
@DELETE
@Path("{lm_id}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response abortLm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, @PathParam("lm_id") int lmId) {
    log.debug("DELETE called for LM {}", mdName + "/" + maName + "/" + mepId + "/" + lmId);
    try {
        MdId mdId = MdIdCharStr.asMdId(mdName);
        MaIdShort maId = MaIdCharStr.asMaId(maName);
        MepId mepIdObj = MepId.valueOf(mepId);
        SoamId lmIdObj = SoamId.valueOf(lmId);
        get(SoamService.class).abortLm(mdId, maId, mepIdObj, lmIdObj);
        return ok("{ \"success\":\"deleted (aborted) " + mdName + "/" + maName + "/" + mepId + "/" + lmId + "\" }").build();
    } catch (CfmConfigException e) {
        log.error("Delete (abort) LM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId + "/" + lmId, e.toString());
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

SoamId (org.onosproject.incubator.net.l2monitoring.soam.SoamId)9 Consumes (javax.ws.rs.Consumes)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)6 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)6 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)6 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)6 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 BufferedReader (java.io.BufferedReader)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStreamReader (java.io.InputStreamReader)2 DELETE (javax.ws.rs.DELETE)2 GET (javax.ws.rs.GET)2 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)2 PUT (javax.ws.rs.PUT)2 WebTarget (javax.ws.rs.client.WebTarget)2 Test (org.junit.Test)2 CfmResourceTest (org.onosproject.cfm.impl.CfmResourceTest)2