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();
}
}
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();
}
}
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();
}
}
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();
}
}
Aggregations