@Activate
  public void activate(ComponentContext context) {
    appId = coreService.registerApplication("org.onosproject.provider.host");

    modified(context);
    providerService = providerRegistry.register(this);
    pktService.addProcessor(processor, 1);
    deviceService.addListener(deviceListener);

    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
    selectorBuilder.matchEthType(Ethernet.TYPE_ARP);
    pktService.requestPackets(selectorBuilder.build(), PacketPriority.CONTROL, appId);

    log.info("Started");
  }
示例#2
0
  @Test
  public void removeHostByDeviceOffline() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }
示例#3
0
  @Test
  public void removeHostByDevicePortDown() {
    provider.modified(CTX_FOR_REMOVE);
    testProcessor.process(new TestArpPacketContext(DEV1));
    testProcessor.process(new TestArpPacketContext(DEV4));

    Device device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 1, providerService.removeCount);

    device =
        new DefaultDevice(
            ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
    deviceService.listener.event(
        new DeviceEvent(PORT_UPDATED, device, new DefaultPort(device, portNumber(INPORT), false)));
    assertEquals("incorrect remove count", 2, providerService.removeCount);
  }