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());
}
}
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());
}
}
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() + "}"));
}
}
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());
}
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));
}
Aggregations