Search in sources :

Example 1 with PacketService

use of org.onosproject.net.packet.PacketService in project onos by opennetworkinglab.

the class NeighbourResolutionManagerTest method setUp.

@Before
public void setUp() throws Exception {
    neighbourManager = new NeighbourResolutionManager();
    packetService = createMock(PacketService.class);
    packetService.requestPackets(anyObject(TrafficSelector.class), anyObject(PacketPriority.class), anyObject(ApplicationId.class));
    expectLastCall().anyTimes();
    packetService.addProcessor(anyObject(PacketProcessor.class), anyInt());
    expectLastCall().andDelegateTo(new TestPacketService()).once();
    packetService.cancelPackets(anyObject(TrafficSelector.class), anyObject(PacketPriority.class), anyObject(ApplicationId.class));
    expectLastCall().anyTimes();
    replay(packetService);
    neighbourManager.packetService = packetService;
    CoreService coreService = createNiceMock(CoreService.class);
    replay(coreService);
    neighbourManager.coreService = coreService;
    neighbourManager.componentConfigService = new ComponentConfigAdapter();
    neighbourManager.activate(new ComponentContextAdapter());
}
Also used : PacketPriority(org.onosproject.net.packet.PacketPriority) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) ComponentContextAdapter(org.onlab.osgi.ComponentContextAdapter) PacketProcessor(org.onosproject.net.packet.PacketProcessor) PacketService(org.onosproject.net.packet.PacketService) TrafficSelector(org.onosproject.net.flow.TrafficSelector) CoreService(org.onosproject.core.CoreService) TestApplicationId(org.onosproject.TestApplicationId) ApplicationId(org.onosproject.core.ApplicationId) Before(org.junit.Before)

Example 2 with PacketService

use of org.onosproject.net.packet.PacketService in project onos by opennetworkinglab.

the class PacketProcessorsWebResource method getPacketProcessors.

/**
 * Gets packet processors. Returns array of all packet processors.
 *
 * @onos.rsModel PacketProcessorsGet
 * @return 200 OK with array of all packet processors.
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getPacketProcessors() {
    PacketService service = get(PacketService.class);
    ObjectNode root = mapper().createObjectNode();
    ArrayNode pktProcNode = root.putArray("packet-processors");
    List<PacketProcessorEntry> processors = service.getProcessors();
    ObjectMapper mapper = new ObjectMapper();
    for (PacketProcessorEntry p : processors) {
        pktProcNode.add(mapper.createObjectNode().put("priority", priorityFormat(p.priority())).put("class", p.processor().getClass().getName()).put("packets", p.invocations()).put("avgNanos", p.averageNanos()));
    }
    return ok(root).build();
}
Also used : PacketService(org.onosproject.net.packet.PacketService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PacketProcessorEntry(org.onosproject.net.packet.PacketProcessorEntry) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with PacketService

use of org.onosproject.net.packet.PacketService in project onos by opennetworkinglab.

the class OFSwitchManager method processOFAgentStarted.

private void processOFAgentStarted(OFAgent ofAgent) {
    devices(ofAgent.networkId()).forEach(deviceId -> {
        OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
        if (ofSwitch != null) {
            connectController(ofSwitch, ofAgent.controllers());
        }
    });
    DeviceService deviceService = virtualNetService.get(ofAgent.networkId(), DeviceService.class);
    deviceService.addListener(deviceListener);
    PacketService packetService = virtualNetService.get(ofAgent.networkId(), PacketService.class);
    packetService.addProcessor(packetProcessor, PacketProcessor.director(0));
    FlowRuleService flowRuleService = virtualNetService.get(ofAgent.networkId(), FlowRuleService.class);
    flowRuleService.addListener(flowRuleListener);
}
Also used : PacketService(org.onosproject.net.packet.PacketService) DeviceService(org.onosproject.net.device.DeviceService) OFSwitch(org.onosproject.ofagent.api.OFSwitch) FlowRuleService(org.onosproject.net.flow.FlowRuleService)

Example 4 with PacketService

use of org.onosproject.net.packet.PacketService in project onos by opennetworkinglab.

the class OFSwitchManager method processOFAgentStopped.

private void processOFAgentStopped(OFAgent ofAgent) {
    devices(ofAgent.networkId()).forEach(deviceId -> {
        OFSwitch ofSwitch = ofSwitchMap.get(deviceId);
        if (ofSwitch != null) {
            disconnectController(ofSwitch, ofAgent.controllers());
        }
    });
    DeviceService deviceService = virtualNetService.get(ofAgent.networkId(), DeviceService.class);
    deviceService.removeListener(deviceListener);
    PacketService packetService = virtualNetService.get(ofAgent.networkId(), PacketService.class);
    packetService.removeProcessor(packetProcessor);
    FlowRuleService flowRuleService = virtualNetService.get(ofAgent.networkId(), FlowRuleService.class);
    flowRuleService.removeListener(flowRuleListener);
}
Also used : PacketService(org.onosproject.net.packet.PacketService) DeviceService(org.onosproject.net.device.DeviceService) OFSwitch(org.onosproject.ofagent.api.OFSwitch) FlowRuleService(org.onosproject.net.flow.FlowRuleService)

Example 5 with PacketService

use of org.onosproject.net.packet.PacketService 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

PacketService (org.onosproject.net.packet.PacketService)6 DeviceService (org.onosproject.net.device.DeviceService)2 FlowRuleService (org.onosproject.net.flow.FlowRuleService)2 TrafficSelector (org.onosproject.net.flow.TrafficSelector)2 PacketPriority (org.onosproject.net.packet.PacketPriority)2 OFSwitch (org.onosproject.ofagent.api.OFSwitch)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 GET (javax.ws.rs.GET)1 Produces (javax.ws.rs.Produces)1 Before (org.junit.Before)1 ComponentContextAdapter (org.onlab.osgi.ComponentContextAdapter)1 TestApplicationId (org.onosproject.TestApplicationId)1 ComponentConfigAdapter (org.onosproject.cfg.ComponentConfigAdapter)1 ApplicationId (org.onosproject.core.ApplicationId)1 CoreService (org.onosproject.core.CoreService)1 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)1 DeviceId (org.onosproject.net.DeviceId)1 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)1