Search in sources :

Example 6 with Up4Service

use of org.omecproject.up4.Up4Service 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 7 with Up4Service

use of org.omecproject.up4.Up4Service in project up4 by omec-project.

the class SessionDownlinkCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4Service app = get(Up4Service.class);
    UpfSessionDownlink.Builder sessBuilder = UpfSessionDownlink.builder().needsBuffering(buff).needsDropping(drop).withUeAddress(Ip4Address.valueOf(ueAddr));
    if (tunnelPeer != -1) {
        sessBuilder.withGtpTunnelPeerId(tunnelPeer);
    }
    if (sessMeterIdx != -1) {
        sessBuilder.withSessionMeterIdx(sessMeterIdx);
    }
    if (delete) {
        app.delete(sessBuilder.build());
    } else {
        app.apply(sessBuilder.build());
    }
}
Also used : Up4Service(org.omecproject.up4.Up4Service) UpfSessionDownlink(org.onosproject.net.behaviour.upf.UpfSessionDownlink)

Example 8 with Up4Service

use of org.omecproject.up4.Up4Service in project up4 by omec-project.

the class ReadInternalUp4StoreCommand method doExecute.

@Override
protected void doExecute() {
    Up4Service up4Service = get(Up4Service.class);
    Up4Store upfStore = get(Up4Store.class);
    if (up4Service == null) {
        print("Error: Up4Service is null");
        return;
    }
    if (upfStore == null) {
        print("Error: FabricUpfStore is null");
        return;
    }
    Set<Ip4Address> bufferUes = upfStore.getBufferUe();
    print("bufferFarIds size: " + bufferUes.size());
    if (verbose) {
        bufferUes.forEach(ue -> print("UEAddress{" + ue.toString() + "}"));
    }
}
Also used : Up4Service(org.omecproject.up4.Up4Service) Ip4Address(org.onlab.packet.Ip4Address) Up4Store(org.omecproject.up4.impl.Up4Store)

Example 9 with Up4Service

use of org.omecproject.up4.Up4Service in project up4 by omec-project.

the class CounterReadCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    UpfCounter stats;
    if (deviceId != null) {
        Up4AdminService app = get(Up4AdminService.class);
        stats = app.readCounter(ctrIndex, DeviceId.deviceId(deviceId));
    } else {
        Up4Service app = get(Up4Service.class);
        stats = app.readCounter(ctrIndex);
    }
    print(stats.toString());
}
Also used : Up4Service(org.omecproject.up4.Up4Service) UpfCounter(org.onosproject.net.behaviour.upf.UpfCounter) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 10 with Up4Service

use of org.omecproject.up4.Up4Service in project up4 by omec-project.

the class InterfaceDeleteCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4Service app = get(Up4Service.class);
    Ip4Address n3Addr = Ip4Address.valueOf(this.n3Addr);
    print("Removing N3 interface address %s", n3Addr.toString());
    app.delete(UpfInterface.createN3From(n3Addr, sliceId));
}
Also used : Up4Service(org.omecproject.up4.Up4Service) Ip4Address(org.onlab.packet.Ip4Address)

Aggregations

Up4Service (org.omecproject.up4.Up4Service)12 Up4AdminService (org.omecproject.up4.impl.Up4AdminService)3 Ip4Address (org.onlab.packet.Ip4Address)2 UpfMeter (org.onosproject.net.behaviour.upf.UpfMeter)2 UpfProgrammableException (org.onosproject.net.behaviour.upf.UpfProgrammableException)2 UpfTerminationDownlink (org.onosproject.net.behaviour.upf.UpfTerminationDownlink)2 UpfTerminationUplink (org.onosproject.net.behaviour.upf.UpfTerminationUplink)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Command (org.apache.karaf.shell.api.action.Command)1 Option (org.apache.karaf.shell.api.action.Option)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 Up4Translator (org.omecproject.up4.Up4Translator)1 Up4Store (org.omecproject.up4.impl.Up4Store)1 AbstractShellCommand (org.onosproject.cli.AbstractShellCommand)1 UpfApplication (org.onosproject.net.behaviour.upf.UpfApplication)1 UpfCounter (org.onosproject.net.behaviour.upf.UpfCounter)1 UpfEntity (org.onosproject.net.behaviour.upf.UpfEntity)1 UpfEntityType (org.onosproject.net.behaviour.upf.UpfEntityType)1