Search in sources :

Example 1 with CfmMepService

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService 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)

Example 2 with CfmMepService

use of org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService 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)

Aggregations

CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)2 CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)2 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)2 ArrayList (java.util.ArrayList)1 MepEntry (org.onosproject.incubator.net.l2monitoring.cfm.MepEntry)1 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)1 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)1 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)1 MepKeyId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)1