use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort in project onos by opennetworkinglab.
the class DmWebResource method createDm.
/**
* Create DM with MD name, MA name, Mep id and DM Json.
*
* @onos.rsModel DmCreate
* @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 belonging to the MEP
* @param input A JSON formatted input stream specifying the DM parameters
* @return 201 Created or 304 if already exists or 500 on error
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createDm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, InputStream input) {
log.debug("POST called to Create Dm");
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MepId mepIdObj = MepId.valueOf(mepId);
Mep mep = get(CfmMepService.class).getMep(mdId, maId, mepIdObj);
if (mep == null) {
return Response.serverError().entity("{ \"failure\":\"mep " + mdName + "/" + maName + "/" + mepId + " does not exist\" }").build();
}
ObjectMapper mapper = new ObjectMapper();
JsonNode cfg = readTreeFromStream(mapper, input);
JsonCodec<DelayMeasurementCreate> dmCodec = codec(DelayMeasurementCreate.class);
DelayMeasurementCreate dm = dmCodec.decode((ObjectNode) cfg, this);
get(SoamService.class).createDm(mdId, maId, mepIdObj, dm);
return Response.created(new URI("md/" + mdName + "/ma/" + maName + "/mep/" + mepId + "/dm")).entity("{ \"success\":\"dm " + mdName + "/" + maName + "/" + mepId + " created\" }").build();
} catch (CfmConfigException | SoamConfigException | IllegalArgumentException | IOException | URISyntaxException e) {
log.error("Create DM on " + mdName + "/" + maName + "/" + mepId + " failed because of exception {}", e.toString());
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort 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.cfm.identifier.MaIdShort 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.cfm.identifier.MaIdShort 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();
}
}
use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort in project onos by opennetworkinglab.
the class MaWebResource method getMa.
/**
* Get Maintenance Association by MD and MA name.
*
* @param mdName The name of a Maintenance Domain
* @param maName The name of a Maintenance Association belonging to the MD
* @return 200 OK with details of MA or 500 on Error
*/
@GET
@Path("{ma_name}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getMa(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName) {
log.debug("GET called for MA {}/{}", mdName, maName);
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MaintenanceAssociation ma = get(CfmMdService.class).getMaintenanceAssociation(mdId, maId).orElseThrow(() -> new IllegalArgumentException("MA " + maName + " not Found"));
ObjectNode node = mapper().createObjectNode();
node.set("ma", codec(MaintenanceAssociation.class).encode(ma, this));
return ok(node).build();
} catch (IllegalArgumentException e) {
log.error("Get MA {} failed", mdName + "/" + maName, e);
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
Aggregations