use of org.onosproject.net.packet.PacketPriority in project onos by opennetworkinglab.
the class PacketRequestCodec method decode.
@Override
public PacketRequest decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
final JsonCodec<TrafficSelector> trafficSelectorCodec = context.codec(TrafficSelector.class);
TrafficSelector trafficSelector = trafficSelectorCodec.decode(get(json, TRAFFIC_SELECTOR), context);
NodeId nodeId = NodeId.nodeId(extractMember(NODE_ID, json));
PacketPriority priority = PacketPriority.valueOf(extractMember(PRIORITY, json));
CoreService coreService = context.getService(CoreService.class);
// TODO check appId (currently hardcoded - should it be read from json node?)
ApplicationId appId = coreService.registerApplication(REST_APP_ID);
DeviceId deviceId = null;
JsonNode node = json.get(DEVICE_ID);
if (node != null) {
deviceId = DeviceId.deviceId(node.asText());
}
return new DefaultPacketRequest(trafficSelector, priority, appId, nodeId, Optional.ofNullable(deviceId));
}
use of org.onosproject.net.packet.PacketPriority in project onos by opennetworkinglab.
the class VirtualNetworkPacketRequestCommand method doExecute.
@Override
protected void doExecute() {
VirtualNetworkService service = get(VirtualNetworkService.class);
PacketService virtualPacketService = service.get(NetworkId.networkId(networkId), PacketService.class);
if (command == null) {
print("Command is not defined");
return;
}
if (command.equals("getRequests")) {
getRequests(virtualPacketService);
return;
}
TrafficSelector selector = buildTrafficSelector();
// TODO allow user to specify
PacketPriority packetPriority = PacketPriority.CONTROL;
Optional<DeviceId> optionalDeviceId = null;
if (!isNullOrEmpty(deviceIdString)) {
optionalDeviceId = Optional.of(DeviceId.deviceId(deviceIdString));
}
if (command.equals("requestPackets")) {
if (optionalDeviceId != null) {
virtualPacketService.requestPackets(selector, packetPriority, appId(), optionalDeviceId);
} else {
virtualPacketService.requestPackets(selector, packetPriority, appId());
}
print("Virtual packet requested:\n%s", selector);
return;
}
if (command.equals("cancelPackets")) {
if (optionalDeviceId != null) {
virtualPacketService.cancelPackets(selector, packetPriority, appId(), optionalDeviceId);
} else {
virtualPacketService.cancelPackets(selector, packetPriority, appId());
}
print("Virtual packet cancelled:\n%s", selector);
return;
}
print("Unsupported command %s", command);
}
Aggregations