Search in sources :

Example 1 with CfmMdService

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

the class CfmMaDeleteCommand method doExecute.

@Override
protected void doExecute() {
    CfmMdService service = get(CfmMdService.class);
    String[] nameParts = name.split("[()]");
    if (nameParts.length != MA_NAME_PARTS_COUNT) {
        throw new IllegalArgumentException("Invalid name format. Must be in " + "the format of <identifier(name-type)identifier(name-type)>");
    }
    MdId mdId = CfmMdListMdCommand.parseMdName(nameParts[0] + "(" + nameParts[1] + ")");
    MaIdShort maId = CfmMdListMdCommand.parseMaName(nameParts[2] + "(" + nameParts[3] + ")");
    try {
        boolean deleted = service.deleteMaintenanceAssociation(mdId, maId);
        print("Maintenance Association %s-%s is %ssuccessfully deleted.", mdId, maId, deleted ? "" : "NOT ");
    } catch (CfmConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : 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)

Example 2 with CfmMdService

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

the class CfmMdDeleteCommand method doExecute.

@Override
protected void doExecute() {
    CfmMdService service = get(CfmMdService.class);
    String[] nameParts = name.split("[()]");
    if (nameParts.length != 2) {
        throw new IllegalArgumentException("Invalid name format. " + "Must be in the format of <identifier(name-type)>");
    }
    MdId mdId = CfmMdListMdCommand.parseMdName(nameParts[0] + "(" + nameParts[1] + ")");
    try {
        boolean deleted = service.deleteMaintenanceDomain(mdId);
        print("Maintenance Domain %s is %ssuccessfully deleted.", mdId, deleted ? "" : "NOT ");
    } catch (CfmConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)

Example 3 with CfmMdService

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

the class CfmMaNameCompleter method choices.

@Override
public List<String> choices() {
    List<String> choices = new ArrayList<>();
    CfmMdService service = get(CfmMdService.class);
    service.getAllMaintenanceDomain().forEach(md -> md.maintenanceAssociationList().forEach(ma -> choices.add(md.mdId().mdName() + "(" + md.mdId().nameType() + ")" + ma.maId().maName() + "(" + ma.maId().nameType() + ")")));
    return choices;
}
Also used : AbstractChoicesCompleter(org.onosproject.cli.AbstractChoicesCompleter) List(java.util.List) Service(org.apache.karaf.shell.api.action.lifecycle.Service) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService) AbstractShellCommand.get(org.onosproject.cli.AbstractShellCommand.get) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)

Example 4 with CfmMdService

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

the class CfmMaAddCommand method doExecute.

@Override
protected void doExecute() {
    CfmMdService service = get(CfmMdService.class);
    String[] mdNameParts = mdName.split("[()]");
    if (mdNameParts.length != 2) {
        throw new IllegalArgumentException("Invalid name format. " + "Must be in the format of <identifier(name-type)>");
    }
    MdId mdId = CfmMdListMdCommand.parseMdName(mdNameParts[0] + "(" + mdNameParts[1] + ")");
    MaIdShort maId = CfmMdListMdCommand.parseMaName(name + "(" + nameType + ")");
    try {
        MaintenanceAssociation.MaBuilder builder = DefaultMaintenanceAssociation.builder(maId, mdId.getNameLength());
        if (ccmInterval != null && !ccmInterval.isEmpty()) {
            builder = builder.ccmInterval(MaintenanceAssociation.CcmInterval.valueOf(ccmInterval));
        }
        for (String rmep : rmepArray) {
            builder = builder.addToRemoteMepIdList(MepId.valueOf(Short.parseShort(rmep)));
        }
        if (numericId != null) {
            builder = builder.maNumericId(numericId);
        }
        if (componentId != null) {
            Component.ComponentBuilder compBuilder = DefaultComponent.builder(componentId);
            if (tagType != null && !tagType.isEmpty()) {
                compBuilder = compBuilder.tagType(Component.TagType.valueOf(tagType));
            }
            if (mhfCreationType != null && !mhfCreationType.isEmpty()) {
                compBuilder = compBuilder.mhfCreationType(Component.MhfCreationType.valueOf(mhfCreationType));
            }
            if (vid != null) {
                compBuilder = compBuilder.addToVidList(VlanId.vlanId(vid));
            }
            builder = builder.addToComponentList(compBuilder.build());
        }
        boolean created = service.createMaintenanceAssociation(mdId, builder.build());
        print("Maintenance Association %s is successfully %s on MD %s", maId, created ? "updated" : "created", mdId);
    } catch (CfmConfigException e) {
        throw new IllegalArgumentException(e);
    }
}
Also used : MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) MaIdShort(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort) DefaultMaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation) MaintenanceAssociation(org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation) Component(org.onosproject.incubator.net.l2monitoring.cfm.Component) DefaultComponent(org.onosproject.incubator.net.l2monitoring.cfm.DefaultComponent) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) CfmMdService(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMdService)

Example 5 with CfmMdService

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

the class CfmMdListMdCommand method doExecute.

@Override
protected void doExecute() {
    CfmMdService service;
    service = get(CfmMdService.class);
    if (name != null) {
        MdId mdId = parseMdName(name);
        print("Maintenance Domain:");
        service.getMaintenanceDomain(mdId).ifPresent(md -> {
            print(printMd(md));
            md.maintenanceAssociationList().forEach(CfmMdListMdCommand::printMa);
        });
    } else {
        service.getAllMaintenanceDomain().forEach(md -> print(printMd(md)));
    }
}
Also used : MdId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId) 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