Search in sources :

Example 16 with MepId

use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId 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();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 17 with MepId

use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId 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();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 18 with MepId

use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId 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();
    }
}
Also used : SoamService(org.onosproject.incubator.net.l2monitoring.soam.SoamService) MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) SoamId(org.onosproject.incubator.net.l2monitoring.soam.SoamId) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 19 with MepId

use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId in project onos by opennetworkinglab.

the class DmCreateCodec method decode.

@Override
public DelayMeasurementCreate decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    JsonNode dmNode = json.get(DM);
    Version version = Version.Y17312011;
    if (dmNode.get(VERSION) != null) {
        version = Version.valueOf(dmNode.get(VERSION).asText());
    }
    DmType dmCfgType = DmType.DMDMM;
    if (dmNode.get(DM_CFG_TYPE) != null) {
        dmCfgType = DmType.valueOf(dmNode.get(DM_CFG_TYPE).asText(DMDMM));
    }
    MepId remoteMepId = MepId.valueOf(nullIsIllegal(dmNode.get(REMOTE_MEP_ID), REMOTE_MEP_ID + " is required").shortValue());
    Priority prio = Priority.valueOf(nullIsIllegal(dmNode.get(PRIORITY), PRIORITY + " is required in the format 'PRIOn'").asText());
    try {
        DmCreateBuilder builder = DefaultDelayMeasurementCreate.builder(dmCfgType, version, remoteMepId, prio);
        if (dmNode.get(MEASUREMENTS_ENABLED) != null) {
            context.codec(MeasurementOption.class).decode((ArrayNode) (dmNode.get(MEASUREMENTS_ENABLED)), context).forEach(builder::addToMeasurementsEnabled);
        }
        if (dmNode.get(BINS_PER_FD_INTERVAL) != null) {
            builder = builder.binsPerFdInterval((short) dmNode.get(BINS_PER_FD_INTERVAL).asInt());
        }
        if (dmNode.get(BINS_PER_IFDV_INTERVAL) != null) {
            builder = builder.binsPerIfdvInterval((short) dmNode.get(BINS_PER_IFDV_INTERVAL).asInt());
        }
        if (dmNode.get(IFDV_SELECTION_OFFSET) != null) {
            builder = builder.ifdvSelectionOffset((short) dmNode.get(IFDV_SELECTION_OFFSET).asInt());
        }
        if (dmNode.get(BINS_PER_FDR_INTERVAL) != null) {
            builder = builder.binsPerFdrInterval((short) dmNode.get(BINS_PER_FDR_INTERVAL).asInt());
        }
        if (dmNode.get(FRAME_SIZE) != null) {
            builder = (DmCreateBuilder) builder.frameSize((short) dmNode.get(FRAME_SIZE).asInt());
        }
        if (dmNode.get(MESSAGE_PERIOD_MS) != null) {
            builder = (DmCreateBuilder) builder.messagePeriod(Duration.ofMillis(dmNode.get(MESSAGE_PERIOD_MS).asInt()));
        }
        if (dmNode.get(MEASUREMENT_INTERVAL_MINS) != null) {
            builder = (DmCreateBuilder) builder.measurementInterval(Duration.ofMinutes(dmNode.get(MEASUREMENT_INTERVAL_MINS).asInt()));
        }
        if (dmNode.get(ALIGN_MEASUREMENT_INTERVALS) != null) {
            builder = (DmCreateBuilder) builder.alignMeasurementIntervals(dmNode.get(ALIGN_MEASUREMENT_INTERVALS).asBoolean());
        }
        if (dmNode.get(ALIGN_MEASUREMENT_OFFSET_MINS) != null) {
            builder = (DmCreateBuilder) builder.alignMeasurementOffset(Duration.ofMinutes(dmNode.get(ALIGN_MEASUREMENT_OFFSET_MINS).asInt()));
        }
        if (dmNode.get(START_TIME) != null) {
            builder = (DmCreateBuilder) builder.startTime(context.codec(StartTime.class).decode((ObjectNode) dmNode.get(START_TIME), context));
        }
        if (dmNode.get(STOP_TIME) != null) {
            builder = (DmCreateBuilder) builder.stopTime(context.codec(StopTime.class).decode((ObjectNode) dmNode.get(STOP_TIME), context));
        }
        return builder.build();
    } catch (SoamConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : DmType(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DmType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) Version(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.Version) Priority(org.onosproject.incubator.net.l2monitoring.cfm.Mep.Priority) DmCreateBuilder(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementCreate.DmCreateBuilder) JsonNode(com.fasterxml.jackson.databind.JsonNode) SoamConfigException(org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)

Example 20 with MepId

use of org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId in project onos by opennetworkinglab.

the class MepWebResource method transmitLinktrace.

/**
 * Transmit Linktrace on MEP with MD name, MA name and Mep Id.
 *
 * @onos.rsModel MepLtTransmit
 * @param mdName The name of a Maintenance Domain
 * @param maName The name of a Maintenance Association belonging to the MD
 * @param mepIdShort The id of a MEP belonging to the MA
 * @param input A JSON formatted input stream specifying the Linktrace parameters
 * @return 202 Received with success message or 500 on error
 */
@PUT
@Path("{mep_id}/transmit-linktrace")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response transmitLinktrace(@PathParam("md_name") String mdName, @PathParam("ma_name") String maName, @PathParam("mep_id") short mepIdShort, InputStream input) {
    log.debug("PUT called to Transmit Linktrace on Mep");
    MdId mdId = MdIdCharStr.asMdId(mdName);
    MaIdShort maId = MaIdCharStr.asMaId(maName);
    MaintenanceDomain md;
    Optional<MaintenanceDomain> mdOpt = get(CfmMdService.class).getMaintenanceDomain(mdId);
    if (mdOpt.isPresent()) {
        md = mdOpt.get();
    } else {
        return Response.serverError().entity("{ \"failure\":\"" + mdName + " does not exist\" }").build();
    }
    MaintenanceAssociation ma;
    Optional<MaintenanceAssociation> maOpt = get(CfmMdService.class).getMaintenanceAssociation(mdId, maId);
    if (maOpt.isPresent()) {
        ma = maOpt.get();
    } else {
        return Response.serverError().entity("{ \"failure\":\"" + maName + " does not exist\" }").build();
    }
    MepId mepId = MepId.valueOf(mepIdShort);
    try {
        ObjectMapper mapper = new ObjectMapper();
        JsonNode cfg = readTreeFromStream(mapper, input);
        JsonCodec<MepLtCreate> mepLtCreateCodec = codec(MepLtCreate.class);
        MepLtCreate ltCreate = mepLtCreateCodec.decode((ObjectNode) cfg, this);
        get(CfmMepService.class).transmitLinktrace(md.mdId(), ma.maId(), mepId, ltCreate);
    } catch (Exception | CfmConfigException e) {
        log.error("Transmit Linktrace on " + mdName + "/" + maName + "/{} failed", String.valueOf(mepIdShort), e);
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
    return Response.accepted().entity("{ \"success\":\"Linktrace on MEP " + mdName + "/" + ma.maId() + "/" + mepId.id() + " started\" }").build();
}
Also used : JsonNode(com.fasterxml.jackson.databind.JsonNode) 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) MepLtCreate(org.onosproject.incubator.net.l2monitoring.cfm.MepLtCreate) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)25 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)17 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)15 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)14 Consumes (javax.ws.rs.Consumes)13 Produces (javax.ws.rs.Produces)13 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)9 Path (javax.ws.rs.Path)9 SoamConfigException (org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)7 Test (org.junit.Test)6 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)6 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)6 SoamId (org.onosproject.incubator.net.l2monitoring.soam.SoamId)6 PUT (javax.ws.rs.PUT)5 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)4 GET (javax.ws.rs.GET)4