Search in sources :

Example 26 with MaIdShort

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

the class CfmMepListCommand method doExecute.

@Override
protected void doExecute() {
    CfmMepService mepService = get(CfmMepService.class);
    CfmMdService mdService = get(CfmMdService.class);
    if (mdStr != null && !mdStr.isEmpty()) {
        MdId mdId = parseMdName(mdStr);
        print(printMdId(mdId));
        if (maStr != null && !maStr.isEmpty()) {
            MaIdShort maId = parseMaName(maStr);
            print(printMaId(maId));
            if (mepStr != null && !mepStr.isEmpty()) {
                MepId mepId = MepId.valueOf(Short.parseShort(mepStr));
                try {
                    MepEntry mep = mepService.getMep(mdId, maId, mepId);
                    if (mep != null) {
                        print(printMepEntry(mep));
                    }
                } catch (CfmConfigException e) {
                    log.error("Error retrieving Mep details {}", new MepKeyId(mdId, maId, mepId), e);
                }
            // MD, MA and MEP given
            } else {
                // MD and MA given but no MEP given
                try {
                    mepService.getAllMeps(mdId, maId).forEach(mep -> print(printMepEntry(mep)));
                } catch (CfmConfigException e) {
                    log.error("Error retrieving Meps for {}/{}", mdId.mdName(), maId.maName(), e);
                }
            }
        } else {
            // MD given but no MA given
            mdService.getAllMaintenanceAssociation(mdId).forEach(ma -> {
                print(printMaId(ma.maId()));
                try {
                    mepService.getAllMeps(mdId, ma.maId()).forEach(mep -> print(printMepEntry(mep)));
                } catch (CfmConfigException e) {
                    log.error("Error retrieving Meps for {}/{}", mdId.mdName(), ma.maId().maName(), e);
                }
            });
        }
    } else {
        mdService.getAllMaintenanceDomain().forEach(md -> {
            print(printMdId(md.mdId()));
            mdService.getAllMaintenanceAssociation(md.mdId()).forEach(ma -> {
                print(printMaId(ma.maId()));
                try {
                    mepService.getAllMeps(md.mdId(), ma.maId()).forEach(mep -> print(printMepEntry(mep)));
                } catch (CfmConfigException e) {
                    log.error("Error retrieving Meps for {}/{}", md.mdId().mdName(), ma.maId().maName(), e);
                }
            });
        });
    }
}
Also used : MepEntry(org.onosproject.incubator.net.l2monitoring.cfm.MepEntry) 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) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService) MepKeyId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId) CfmMepService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)

Aggregations

MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)26 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)23 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)23 Consumes (javax.ws.rs.Consumes)19 Produces (javax.ws.rs.Produces)19 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)15 Path (javax.ws.rs.Path)13 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)10 SoamService (org.onosproject.incubator.net.l2monitoring.soam.SoamService)10 JsonNode (com.fasterxml.jackson.databind.JsonNode)7 GET (javax.ws.rs.GET)7 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)7 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)6 SoamConfigException (org.onosproject.incubator.net.l2monitoring.soam.SoamConfigException)6 SoamId (org.onosproject.incubator.net.l2monitoring.soam.SoamId)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 PUT (javax.ws.rs.PUT)5 DELETE (javax.ws.rs.DELETE)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3