use of org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException in project onos by opennetworkinglab.
the class DmWebResource method getAllDmsForMep.
/**
* Get all DMs for a Mep.
*
* @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 a Mep belonging to the MA
* @return 200 OK with a list of DMs or 500 on error
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getAllDmsForMep(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId) {
log.debug("GET all DMs called for MEP {}", mdName + "/" + maName + "/" + mepId);
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MepId mepIdObj = MepId.valueOf(mepId);
Collection<DelayMeasurementEntry> dmCollection = get(SoamService.class).getAllDms(mdId, maId, mepIdObj);
ArrayNode an = mapper().createArrayNode();
an.add(codec(DelayMeasurementEntry.class).encode(dmCollection, this));
return ok(mapper().createObjectNode().set("dms", an)).build();
} catch (CfmConfigException | SoamConfigException e) {
log.error("Get DM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId, e.toString());
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
use of org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException in project onos by opennetworkinglab.
the class DmWebResource method getDm.
/**
* Get DM 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 dmId The Id of the DM
* @return 200 OK with details of the DM or 500 on error
*/
@GET
@Path("{dm_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getDm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, @PathParam("dm_id") int dmId) {
log.debug("GET 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);
DelayMeasurementEntry dm = get(SoamService.class).getDm(mdId, maId, mepIdObj, dmIdObj);
if (dm == null) {
return Response.serverError().entity("{ \"failure\":\"DM " + mdName + "/" + maName + "/" + mepId + "/" + dmId + " not found\" }").build();
}
ObjectNode node = mapper().createObjectNode();
node.set("dm", codec(DelayMeasurementEntry.class).encode(dm, this));
return ok(node).build();
} catch (CfmConfigException | SoamConfigException e) {
log.error("Get 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.SoamConfigException 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.SoamConfigException in project onos by opennetworkinglab.
the class LmWebResource method getAllLmsForMep.
/**
* Get all LMs for a Mep.
*
* @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 a Mep belonging to the MA
* @return 200 OK with a list of LMs or 500 on error
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getAllLmsForMep(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId) {
log.debug("GET all LMs called for MEP {}", mdName + "/" + maName + "/" + mepId);
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MepId mepIdObj = MepId.valueOf(mepId);
Collection<LossMeasurementEntry> lmCollection = get(SoamService.class).getAllLms(mdId, maId, mepIdObj);
ArrayNode an = mapper().createArrayNode();
an.add(codec(LossMeasurementEntry.class).encode(lmCollection, this));
return ok(mapper().createObjectNode().set("lms", an)).build();
} catch (CfmConfigException | SoamConfigException e) {
log.error("Get LM {} failed because of exception {}", mdName + "/" + maName + "/" + mepId, e.toString());
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
use of org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException in project onos by opennetworkinglab.
the class LmWebResource method createLm.
/**
* Create LM with MD name, MA name, Mep id and LM Json.
*
* @onos.rsModel LmCreate
* @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 LM parameters
* @return 201 Created or 304 if already exists or 500 on error
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createLm(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepId, InputStream input) {
log.debug("POST called to Create Lm");
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<LossMeasurementCreate> lmCodec = codec(LossMeasurementCreate.class);
LossMeasurementCreate lm = lmCodec.decode((ObjectNode) cfg, this);
get(SoamService.class).createLm(mdId, maId, mepIdObj, lm);
return Response.created(new URI("md/" + mdName + "/ma/" + maName + "/mep/" + mepId + "/lm")).entity("{ \"success\":\"lm " + mdName + "/" + maName + "/" + mepId + " created\" }").build();
} catch (CfmConfigException | SoamConfigException | IllegalArgumentException | IOException | URISyntaxException e) {
log.error("Create LM on " + mdName + "/" + maName + "/" + mepId + " failed because of exception {}", e.toString());
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
Aggregations