Search in sources :

Example 1 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService in project up4 by omec-project.

the class UePoolDeleteCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4AdminService app = get(Up4AdminService.class);
    Ip4Prefix poolPrefix = Ip4Prefix.valueOf(this.poolPrefix);
    print("Deleting UE IPv4 address pool prefix: %s", poolPrefix);
    app.adminDelete(UpfInterface.createUePoolFrom(poolPrefix, sliceId));
}
Also used : Up4AdminService(org.omecproject.up4.impl.Up4AdminService) Ip4Prefix(org.onlab.packet.Ip4Prefix)

Example 2 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService in project up4 by omec-project.

the class ResetEntriesCommand method doExecute.

@Override
protected void doExecute() throws UpfProgrammableException {
    Up4AdminService app = get(Up4AdminService.class);
    print("Clearing all UP4 dataplane table entries.");
    app.adminDeleteAll(UpfEntityType.SESSION_UPLINK);
    app.adminDeleteAll(UpfEntityType.SESSION_DOWNLINK);
    app.adminDeleteAll(UpfEntityType.TERMINATION_UPLINK);
    app.adminDeleteAll(UpfEntityType.TERMINATION_DOWNLINK);
    app.adminDeleteAll(UpfEntityType.TUNNEL_PEER);
    app.adminReadAll(UpfEntityType.INTERFACE);
    Collection<UpfInterface> configInterfaces = app.configInterfaces();
    // Remove only the interfaces from UP4 config
    for (UpfInterface upfInterface : configInterfaces) {
        app.adminDelete(upfInterface);
    }
    app.resetAllSessionMeters();
    app.resetAllApplicationMeters();
    print("Reinstalling UP4 interfaces and DBUF GTP Tunnel from app configuration.");
    app.installUpfEntities();
}
Also used : UpfInterface(org.onosproject.net.behaviour.upf.UpfInterface) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 3 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService in project up4 by omec-project.

the class ClearFlowsCommand method doExecute.

@Override
protected void doExecute() throws UpfProgrammableException {
    Up4Service app = get(Up4Service.class);
    Up4AdminService adminApp = get(Up4AdminService.class);
    print("Clearing all currently installed UE sessions.");
    app.deleteAll(UpfEntityType.APPLICATION);
    app.deleteAll(UpfEntityType.SESSION_DOWNLINK);
    app.deleteAll(UpfEntityType.SESSION_UPLINK);
    app.deleteAll(UpfEntityType.TERMINATION_DOWNLINK);
    app.deleteAll(UpfEntityType.TERMINATION_UPLINK);
    app.deleteAll(UpfEntityType.TUNNEL_PEER);
    adminApp.resetAllSessionMeters();
    adminApp.resetAllApplicationMeters();
}
Also used : Up4Service(org.omecproject.up4.Up4Service) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 4 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService in project up4 by omec-project.

the class ReadUpfEntitiesCommand method doExecute.

@Override
protected void doExecute() {
    Up4AdminService up4Admin = get(Up4AdminService.class);
    Up4Service up4Service = get(Up4Service.class);
    boolean filterCounters = false;
    try {
        List<UpfEntityType> printedTypes = new ArrayList<>();
        if (all) {
            printedTypes.add(UpfEntityType.APPLICATION);
            printedTypes.add(UpfEntityType.SESSION_UPLINK);
            printedTypes.add(UpfEntityType.SESSION_DOWNLINK);
            printedTypes.add(UpfEntityType.TERMINATION_UPLINK);
            printedTypes.add(UpfEntityType.TERMINATION_DOWNLINK);
            printedTypes.add(UpfEntityType.TUNNEL_PEER);
            printedTypes.add(UpfEntityType.INTERFACE);
            printedTypes.add(UpfEntityType.SESSION_METER);
            printedTypes.add(UpfEntityType.APPLICATION_METER);
            filterCounters = true;
        } else if (ue) {
            printedTypes.add(UpfEntityType.APPLICATION);
            printedTypes.add(UpfEntityType.SESSION_UPLINK);
            printedTypes.add(UpfEntityType.SESSION_DOWNLINK);
            printedTypes.add(UpfEntityType.TERMINATION_UPLINK);
            printedTypes.add(UpfEntityType.TERMINATION_DOWNLINK);
            printedTypes.add(UpfEntityType.TUNNEL_PEER);
            printedTypes.add(UpfEntityType.SESSION_METER);
            printedTypes.add(UpfEntityType.APPLICATION_METER);
            filterCounters = true;
        } else {
            if (application) {
                printedTypes.add(UpfEntityType.APPLICATION);
            }
            if (sessions) {
                printedTypes.add(UpfEntityType.SESSION_UPLINK);
                printedTypes.add(UpfEntityType.SESSION_DOWNLINK);
            }
            if (termination) {
                printedTypes.add(UpfEntityType.TERMINATION_UPLINK);
                printedTypes.add(UpfEntityType.TERMINATION_DOWNLINK);
            }
            if (tunnels) {
                printedTypes.add(UpfEntityType.TUNNEL_PEER);
            }
            if (counters) {
                printedTypes.add(UpfEntityType.COUNTER);
                filterCounters = false;
            }
            if (interfaces) {
                printedTypes.add(UpfEntityType.INTERFACE);
            }
            if (appMeters) {
                printedTypes.add(UpfEntityType.APPLICATION_METER);
            }
            if (sessMeters) {
                printedTypes.add(UpfEntityType.SESSION_METER);
            }
        }
        for (var type : printedTypes) {
            if (type.equals(UpfEntityType.TERMINATION_UPLINK)) {
                Collection<? extends UpfEntity> terminations = up4Admin.adminReadAll(type);
                for (var t : terminations) {
                    UpfTerminationUplink term = (UpfTerminationUplink) t;
                    print(term.toString());
                    if (filterCounters) {
                        print(up4Service.readCounter(term.counterId()).toString());
                    }
                }
            } else if (type.equals(UpfEntityType.TERMINATION_DOWNLINK)) {
                Collection<? extends UpfEntity> terminations = up4Admin.adminReadAll(type);
                for (var t : terminations) {
                    UpfTerminationDownlink term = (UpfTerminationDownlink) t;
                    print(term.toString());
                    if (filterCounters) {
                        print(up4Service.readCounter(term.counterId()).toString());
                    }
                }
            } else {
                up4Admin.adminReadAll(type).forEach(upfEntity -> print(upfEntity.toString()));
            }
        }
    } catch (UpfProgrammableException e) {
        print("Error while reading UPF entity: " + e.getMessage());
    }
}
Also used : UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) Collection(java.util.Collection) Command(org.apache.karaf.shell.api.action.Command) ArrayList(java.util.ArrayList) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) List(java.util.List) Up4Service(org.omecproject.up4.Up4Service) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Service(org.apache.karaf.shell.api.action.lifecycle.Service) UpfEntityType(org.onosproject.net.behaviour.upf.UpfEntityType) Option(org.apache.karaf.shell.api.action.Option) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink) Up4AdminService(org.omecproject.up4.impl.Up4AdminService) UpfTerminationDownlink(org.onosproject.net.behaviour.upf.UpfTerminationDownlink) ArrayList(java.util.ArrayList) UpfEntityType(org.onosproject.net.behaviour.upf.UpfEntityType) UpfTerminationUplink(org.onosproject.net.behaviour.upf.UpfTerminationUplink) Up4Service(org.omecproject.up4.Up4Service) UpfProgrammableException(org.onosproject.net.behaviour.upf.UpfProgrammableException) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Collection(java.util.Collection) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 5 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService in project up4 by omec-project.

the class GtpTunnelPeerCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4AdminService app = get(Up4AdminService.class);
    UpfGtpTunnelPeer.Builder tunnelPeerBuilder = UpfGtpTunnelPeer.builder().withTunnelPeerId(tunnelPeer).withSrcAddr(Ip4Address.valueOf(srcAddr)).withDstAddr(Ip4Address.valueOf(dstAddr));
    if (srcPort != -1) {
        tunnelPeerBuilder.withSrcPort(srcPort);
    }
    if (delete) {
        app.adminDelete(tunnelPeerBuilder.build());
    } else {
        app.adminApply(tunnelPeerBuilder.build());
    }
}
Also used : Up4AdminService(org.omecproject.up4.impl.Up4AdminService) UpfGtpTunnelPeer(org.onosproject.net.behaviour.upf.UpfGtpTunnelPeer)

Aggregations

Up4AdminService (org.omecproject.up4.impl.Up4AdminService)9 Up4Service (org.omecproject.up4.Up4Service)3 Collection (java.util.Collection)2 Command (org.apache.karaf.shell.api.action.Command)2 Service (org.apache.karaf.shell.api.action.lifecycle.Service)2 Ip4Prefix (org.onlab.packet.Ip4Prefix)2 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)2 UpfEntity (org.onosproject.net.behaviour.upf.UpfEntity)2 UpfEntityType (org.onosproject.net.behaviour.upf.UpfEntityType)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 Option (org.apache.karaf.shell.api.action.Option)1 DownlinkUpfFlow (org.omecproject.up4.impl.DownlinkUpfFlow)1 Up4Utils.ppUpfMeter (org.omecproject.up4.impl.Up4Utils.ppUpfMeter)1 UplinkUpfFlow (org.omecproject.up4.impl.UplinkUpfFlow)1 Ip4Address (org.onlab.packet.Ip4Address)1 UpfApplication (org.onosproject.net.behaviour.upf.UpfApplication)1 UpfCounter (org.onosproject.net.behaviour.upf.UpfCounter)1