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();
}
}
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();
}
}
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);
}
}
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;
}
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();
}
}
Aggregations