Search in sources :

Example 36 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException 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 37 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException 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 38 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class CfmMdAddCommand method doExecute.

@Override
protected void doExecute() {
    CfmMdService service = get(CfmMdService.class);
    MdId mdId = CfmMdListMdCommand.parseMdName(name + "(" + nameType + ")");
    MaintenanceDomain.MdLevel levelEnum = MaintenanceDomain.MdLevel.valueOf(level);
    try {
        MaintenanceDomain.MdBuilder builder = DefaultMaintenanceDomain.builder(mdId).mdLevel(levelEnum);
        if (numericId != null) {
            builder = builder.mdNumericId(numericId);
        }
        boolean created = service.createMaintenanceDomain(builder.build());
        print("Maintenance Domain with id %s is successfully %s.", mdId, created ? "updated" : "created");
    } catch (CfmConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) DefaultMaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain) MaintenanceDomain(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)

Example 39 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class CfmMepIdCompleter method choices.

@Override
public List<String> choices() {
    List<String> choices = new ArrayList<>();
    CfmMdService mdService = get(CfmMdService.class);
    CfmMepService mepService = get(CfmMepService.class);
    mdService.getAllMaintenanceDomain().forEach(md -> {
        choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ")");
        md.maintenanceAssociationList().forEach(ma -> {
            choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ") " + ma.maId().maName() + "(" + ma.maId().nameType() + ")");
            try {
                mepService.getAllMeps(md.mdId(), ma.maId()).forEach(mep -> choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ") " + ma.maId().maName() + "(" + ma.maId().nameType() + ") " + mep.mepId()));
            } catch (CfmConfigException e) {
                log.warn("Unable to retrieve mep details", e);
            }
        });
    });
    return choices;
}
Also used : ArrayList(java.util.ArrayList) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService) CfmMepService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)

Example 40 with CfmConfigException

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException in project onos by opennetworkinglab.

the class DeviceMepWebResource method getAllMepsForDevice.

/**
 * Get all MEPs by Device Id. The device should support Meps
 *
 * @param deviceId The id of a device.
 * @return 200 OK with a list of MEPS or 500 on error
 */
@GET
@Path("{device_id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response getAllMepsForDevice(@PathParam("device_id") String deviceId) {
    DeviceId deviceIdObj = DeviceId.deviceId(deviceId);
    log.debug("GET all Meps called for Device {}", deviceIdObj);
    try {
        Collection<Mep> mepCollection = get(CfmMepService.class).getAllMepsByDevice(deviceIdObj);
        ArrayNode an = mapper().createArrayNode();
        an.add(codec(Mep.class).encode(mepCollection, this));
        return ok(mapper().createObjectNode().set("meps", an)).build();
    } catch (CfmConfigException e) {
        log.error("Get all Meps on device {} failed because of exception", deviceIdObj, e);
        return Response.serverError().entity("{ \"failure\":\"" + e.toString() + "\" }").build();
    }
}
Also used : DeviceId(org.onosproject.net.DeviceId) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMepService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Consumes(javax.ws.rs.Consumes) GET(javax.ws.rs.GET)

Aggregations

CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)50 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)27 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)23 Consumes (javax.ws.rs.Consumes)22 Produces (javax.ws.rs.Produces)22 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)17 Path (javax.ws.rs.Path)14 Mep (org.onosproject.incubator.net.l2monitoring.cfm.Mep)14 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)13 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)12 DeviceId (org.onosproject.net.DeviceId)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)10 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)10 MepEntry (org.onosproject.incubator.net.l2monitoring.cfm.MepEntry)9 CfmMepProgrammable (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)7 GET (javax.ws.rs.GET)7 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)7 MepKeyId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)7 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)6