Search in sources :

Example 6 with Up4AdminService

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

the class InterfaceInsertCommand method doExecute.

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

Example 7 with Up4AdminService

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

the class ReadFlowsCommand method doExecute.

@Override
protected void doExecute() throws Exception {
    Up4AdminService adminService = get(Up4AdminService.class);
    Collection<DownlinkUpfFlow> dlUpfFlow = adminService.getDownlinkFlows();
    Collection<UplinkUpfFlow> ulUpfFlow = adminService.getUplinkFlows();
    Collection<? extends UpfEntity> ulSess = adminService.adminReadAll(UpfEntityType.SESSION_UPLINK);
    Collection<? extends UpfEntity> appFilters = adminService.adminReadAll(UpfEntityType.APPLICATION);
    // Get session and app meter only to show the number of meters
    Collection<? extends UpfEntity> sessMeters = adminService.adminReadAll(UpfEntityType.SESSION_METER);
    Map<Integer, UpfMeter> sessMeterMap = sessMeters.stream().map(m -> (UpfMeter) m).collect(Collectors.toMap(UpfMeter::cellId, m -> m));
    Collection<? extends UpfEntity> appMeters = adminService.adminReadAll(UpfEntityType.APPLICATION_METER);
    print(SEPARATOR);
    print(appFilters.size() + " Applications");
    for (UpfEntity a : appFilters) {
        if (!a.type().equals(UpfEntityType.APPLICATION)) {
            print("ERROR: Wrong application filter: " + a);
            continue;
        }
        UpfApplication app = (UpfApplication) a;
        print("app_id=" + app.appId() + ", ipv4_prefix=" + app.ip4Prefix() + ", l4_range=" + app.l4PortRange() + ", ip_proto=" + app.ipProto());
    }
    print(SEPARATOR);
    print(ulSess.size() + " Uplink Sessions");
    for (UpfEntity s : ulSess) {
        if (!s.type().equals(UpfEntityType.SESSION_UPLINK)) {
            print("ERROR: Wrong uplink session: " + s);
            continue;
        }
        UpfSessionUplink sess = (UpfSessionUplink) s;
        print("n3_addr=" + sess.tunDstAddr() + ", teid=" + sess.teid() + (sess.needsDropping() ? ", drop()" : ", fwd(" + "sess_meter_idx=" + sess.sessionMeterIdx() + ")"));
        UpfMeter sessMeter = sessMeterMap.getOrDefault(sess.sessionMeterIdx(), null);
        if (sessMeter == null) {
            print("    NO SESSION METER (sess_meter_idx=" + sess.sessionMeterIdx() + ")");
        } else {
            print("    Session meter: " + ppUpfMeter(sessMeter));
        }
    }
    print(SEPARATOR);
    print(ulUpfFlow.size() + " Uplink Flows");
    for (UplinkUpfFlow f : ulUpfFlow) {
        print(f.toString());
    }
    print(SEPARATOR);
    print(dlUpfFlow.size() + " Downlink Flows");
    for (DownlinkUpfFlow f : dlUpfFlow) {
        print(f.toString());
    }
    print(SEPARATOR);
    print("Apps=%d, UL sess=%d, UL flows=%d, DL flows=%s", appFilters.size(), ulSess.size(), ulUpfFlow.size(), dlUpfFlow.size());
    print("App meters=%d, Sess meters=%d", appMeters.size(), sessMeters.size());
}
Also used : UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Collection(java.util.Collection) DownlinkUpfFlow(org.omecproject.up4.impl.DownlinkUpfFlow) UpfSessionUplink(org.onosproject.net.behaviour.upf.UpfSessionUplink) Collectors(java.util.stream.Collectors) Command(org.apache.karaf.shell.api.action.Command) Up4Utils.ppUpfMeter(org.omecproject.up4.impl.Up4Utils.ppUpfMeter) AbstractShellCommand(org.onosproject.cli.AbstractShellCommand) UplinkUpfFlow(org.omecproject.up4.impl.UplinkUpfFlow) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Map(java.util.Map) Service(org.apache.karaf.shell.api.action.lifecycle.Service) UpfEntityType(org.onosproject.net.behaviour.upf.UpfEntityType) UpfApplication(org.onosproject.net.behaviour.upf.UpfApplication) Up4AdminService(org.omecproject.up4.impl.Up4AdminService) UpfSessionUplink(org.onosproject.net.behaviour.upf.UpfSessionUplink) DownlinkUpfFlow(org.omecproject.up4.impl.DownlinkUpfFlow) UpfMeter(org.onosproject.net.behaviour.upf.UpfMeter) Up4Utils.ppUpfMeter(org.omecproject.up4.impl.Up4Utils.ppUpfMeter) UpfApplication(org.onosproject.net.behaviour.upf.UpfApplication) UplinkUpfFlow(org.omecproject.up4.impl.UplinkUpfFlow) UpfEntity(org.onosproject.net.behaviour.upf.UpfEntity) Up4AdminService(org.omecproject.up4.impl.Up4AdminService)

Example 8 with Up4AdminService

use of org.omecproject.up4.impl.Up4AdminService 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 9 with Up4AdminService

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

the class UePoolInsertCommand method doExecute.

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

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