Search in sources :

Example 1 with MepCodec

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");
}
Also used : LossMeasurementStatCurrentCodec(org.onosproject.soam.web.LossMeasurementStatCurrentCodec) DmMeasurementOptionCodec(org.onosproject.soam.web.DmMeasurementOptionCodec) LossMeasurementThresholdCodec(org.onosproject.soam.web.LossMeasurementThresholdCodec) LossAvailabilityStatCurrentCodec(org.onosproject.soam.web.LossAvailabilityStatCurrentCodec) LossMeasurementStatHistoryCodec(org.onosproject.soam.web.LossMeasurementStatHistoryCodec) MepLbEntryCodec(org.onosproject.cfm.web.MepLbEntryCodec) LmThresholdOptionCodec(org.onosproject.soam.web.LmThresholdOptionCodec) LossAvailabilityStatCodec(org.onosproject.soam.web.LossAvailabilityStatCodec) LossAvailabilityStatHistoryCodec(org.onosproject.soam.web.LossAvailabilityStatHistoryCodec) MepLbCreateCodec(org.onosproject.cfm.web.MepLbCreateCodec) ComponentCodec(org.onosproject.cfm.web.ComponentCodec) StopTimeCodec(org.onosproject.soam.web.StopTimeCodec) DelayMeasurementStatCodec(org.onosproject.soam.web.DelayMeasurementStatCodec) FngAddressCodec(org.onosproject.cfm.web.FngAddressCodec) LmCreateCodec(org.onosproject.soam.web.LmCreateCodec) MaintenanceAssociationCodec(org.onosproject.cfm.web.MaintenanceAssociationCodec) MaintenanceDomainCodec(org.onosproject.cfm.web.MaintenanceDomainCodec) MepCodec(org.onosproject.cfm.web.MepCodec) LmCounterOptionCodec(org.onosproject.soam.web.LmCounterOptionCodec) StartTimeCodec(org.onosproject.soam.web.StartTimeCodec) LossMeasurementThreshold(org.onosproject.incubator.net.l2monitoring.soam.loss.LossMeasurementThreshold) RemoteMepEntryCodec(org.onosproject.cfm.web.RemoteMepEntryCodec) MepEntryCodec(org.onosproject.cfm.web.MepEntryCodec) DmCreateCodec(org.onosproject.soam.web.DmCreateCodec) MepLtCreateCodec(org.onosproject.cfm.web.MepLtCreateCodec) RemoteMepEntryCodec(org.onosproject.cfm.web.RemoteMepEntryCodec) LmEntryCodec(org.onosproject.soam.web.LmEntryCodec) VidCodec(org.onosproject.cfm.web.VidCodec) DelayMeasurementStatHistoryCodec(org.onosproject.soam.web.DelayMeasurementStatHistoryCodec) LossMeasurementStatCodec(org.onosproject.soam.web.LossMeasurementStatCodec) DmEntryCodec(org.onosproject.soam.web.DmEntryCodec) DelayMeasurementStatCurrentCodec(org.onosproject.soam.web.DelayMeasurementStatCurrentCodec) Activate(org.osgi.service.component.annotations.Activate)

Example 2 with MepCodec

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();
    }
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) MepCodec(org.onosproject.cfm.web.MepCodec) URI(java.net.URI) CfmMepService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Aggregations

MepCodec (org.onosproject.cfm.web.MepCodec)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 URI (java.net.URI)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 ComponentCodec (org.onosproject.cfm.web.ComponentCodec)1 FngAddressCodec (org.onosproject.cfm.web.FngAddressCodec)1 MaintenanceAssociationCodec (org.onosproject.cfm.web.MaintenanceAssociationCodec)1 MaintenanceDomainCodec (org.onosproject.cfm.web.MaintenanceDomainCodec)1 MepEntryCodec (org.onosproject.cfm.web.MepEntryCodec)1 MepLbCreateCodec (org.onosproject.cfm.web.MepLbCreateCodec)1 MepLbEntryCodec (org.onosproject.cfm.web.MepLbEntryCodec)1 MepLtCreateCodec (org.onosproject.cfm.web.MepLtCreateCodec)1 RemoteMepEntryCodec (org.onosproject.cfm.web.RemoteMepEntryCodec)1 VidCodec (org.onosproject.cfm.web.VidCodec)1 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)1 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)1 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)1