use of org.onosproject.cfm.web.MepCodec in project onos by opennetworkinglab.
the class CfmWebComponent method activate.
/**
* On activation of this component register these codecs with the codec service.
*/
@Activate
public void activate() {
codecService.registerCodec(MaintenanceDomain.class, new MaintenanceDomainCodec());
codecService.registerCodec(MaintenanceAssociation.class, new MaintenanceAssociationCodec());
codecService.registerCodec(org.onosproject.incubator.net.l2monitoring.cfm.Component.class, new ComponentCodec());
codecService.registerCodec(VlanId.class, new VidCodec());
codecService.registerCodec(Mep.class, new MepCodec());
codecService.registerCodec(MepEntry.class, new MepEntryCodec());
codecService.registerCodec(MepLbCreate.class, new MepLbCreateCodec());
codecService.registerCodec(MepLbEntry.class, new MepLbEntryCodec());
codecService.registerCodec(MepLtCreate.class, new MepLtCreateCodec());
codecService.registerCodec(RemoteMepEntry.class, new RemoteMepEntryCodec());
codecService.registerCodec(FngAddress.class, new FngAddressCodec());
codecService.registerCodec(DelayMeasurementCreate.class, new DmCreateCodec());
codecService.registerCodec(DelayMeasurementEntry.class, new DmEntryCodec());
codecService.registerCodec(DelayMeasurementStat.class, new DelayMeasurementStatCodec());
codecService.registerCodec(DelayMeasurementStatCurrent.class, new DelayMeasurementStatCurrentCodec());
codecService.registerCodec(DelayMeasurementStatHistory.class, new DelayMeasurementStatHistoryCodec());
codecService.registerCodec(MeasurementOption.class, new DmMeasurementOptionCodec());
codecService.registerCodec(LossMeasurementCreate.class, new LmCreateCodec());
codecService.registerCodec(LossMeasurementThreshold.class, new LossMeasurementThresholdCodec());
codecService.registerCodec(LossMeasurementEntry.class, new LmEntryCodec());
codecService.registerCodec(LossMeasurementStat.class, new LossMeasurementStatCodec());
codecService.registerCodec(LossMeasurementStatCurrent.class, new LossMeasurementStatCurrentCodec());
codecService.registerCodec(LossMeasurementStatHistory.class, new LossMeasurementStatHistoryCodec());
codecService.registerCodec(LossAvailabilityStat.class, new LossAvailabilityStatCodec());
codecService.registerCodec(LossAvailabilityStatCurrent.class, new LossAvailabilityStatCurrentCodec());
codecService.registerCodec(LossAvailabilityStatHistory.class, new LossAvailabilityStatHistoryCodec());
codecService.registerCodec(CounterOption.class, new LmCounterOptionCodec());
codecService.registerCodec(LossMeasurementThreshold.ThresholdOption.class, new LmThresholdOptionCodec());
codecService.registerCodec(StartTime.class, new StartTimeCodec());
codecService.registerCodec(StopTime.class, new StopTimeCodec());
log.info("CFM Web Component Started");
}
use of org.onosproject.cfm.web.MepCodec in project onos by opennetworkinglab.
the class MepWebResource method createMep.
/**
* Create MEP with MD name, MA name and Mep Json.
*
* @onos.rsModel MepCreate
* @param mdName The name of a Maintenance Domain
* @param maName The name of a Maintenance Association belonging to the MD
* @param input A JSON formatted input stream specifying the Mep parameters
* @return 201 Created or 304 if already exists or 500 on error
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createMep(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, InputStream input) {
log.debug("POST called to Create Mep");
try {
MdId mdId = MdIdCharStr.asMdId(mdName);
MaIdShort maId = MaIdCharStr.asMaId(maName);
MaintenanceAssociation ma = get(CfmMdService.class).getMaintenanceAssociation(mdId, maId).orElseThrow(() -> new IllegalArgumentException("MA " + mdName + "/" + maName + " not Found"));
ObjectMapper mapper = new ObjectMapper();
JsonNode cfg = readTreeFromStream(mapper(), input);
JsonCodec<Mep> mepCodec = codec(Mep.class);
Mep mep = ((MepCodec) mepCodec).decode((ObjectNode) cfg, this, mdName, maName);
Boolean didNotExist = get(CfmMepService.class).createMep(mdId, maId, mep);
if (!didNotExist) {
return Response.notModified(mdName + "/" + ma.maId() + "/" + mep.mepId() + " already exists").build();
}
return Response.created(new URI("md/" + mdName + "/ma/" + ma.maId() + "/mep/" + mep.mepId())).entity("{ \"success\":\"mep " + mdName + "/" + ma.maId() + "/" + mep.mepId() + " created\" }").build();
} catch (Exception | CfmConfigException e) {
log.error("Create Mep on " + mdName + "/" + maName + " failed because of exception {}", e);
return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
}
}
Aggregations