Search in sources :

Example 6 with CfmMdService

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

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

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

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

the class CfmMdNameCompleter method choices.

@Override
public List<String> choices() {
    List<String> choices = new ArrayList<>();
    CfmMdService service = get(CfmMdService.class);
    service.getAllMaintenanceDomain().forEach(md -> choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ")"));
    return choices;
}
Also used : ArrayList(java.util.ArrayList) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)

Aggregations

CfmMdService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)9 MdId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId)6 CfmConfigException (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException)6 ArrayList (java.util.ArrayList)3 MaIdShort (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort)3 CfmMepService (org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepService)2 List (java.util.List)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 AbstractChoicesCompleter (org.onosproject.cli.AbstractChoicesCompleter)1 AbstractShellCommand.get (org.onosproject.cli.AbstractShellCommand.get)1 Component (org.onosproject.incubator.net.l2monitoring.cfm.Component)1 DefaultComponent (org.onosproject.incubator.net.l2monitoring.cfm.DefaultComponent)1 DefaultMaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation)1 DefaultMaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain)1 MaintenanceAssociation (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation)1 MaintenanceDomain (org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain)1 MepEntry (org.onosproject.incubator.net.l2monitoring.cfm.MepEntry)1 MepId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId)1 MepKeyId (org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId)1