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