Search in sources :

Example 1 with PacketPriority

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));
}
Also used : PacketPriority(org.onosproject.net.packet.PacketPriority) DefaultPacketRequest(org.onosproject.net.packet.DefaultPacketRequest) DeviceId(org.onosproject.net.DeviceId) NodeId(org.onosproject.cluster.NodeId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CoreService(org.onosproject.core.CoreService) JsonNode(com.fasterxml.jackson.databind.JsonNode) ApplicationId(org.onosproject.core.ApplicationId)

Example 2 with PacketPriority

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);
}
Also used : PacketPriority(org.onosproject.net.packet.PacketPriority) PacketService(org.onosproject.net.packet.PacketService) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) DeviceId(org.onosproject.net.DeviceId) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Aggregations

DeviceId (org.onosproject.net.DeviceId)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 PacketPriority (org.onosproject.net.packet.PacketPriority)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 NodeId (org.onosproject.cluster.NodeId)1 ApplicationId (org.onosproject.core.ApplicationId)1 CoreService (org.onosproject.core.CoreService)1 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1 DefaultPacketRequest (org.onosproject.net.packet.DefaultPacketRequest)1 PacketService (org.onosproject.net.packet.PacketService)1