Search in sources :

Example 1 with DeviceListener

use of org.onosproject.net.device.DeviceListener in project onos by opennetworkinglab.

the class ControlPlaneRedirectManagerTest method setUp.

@Before
public void setUp() {
    networkConfigListener = createMock(NetworkConfigListener.class);
    deviceService = new TestDeviceService();
    deviceListener = createMock(DeviceListener.class);
    interfaceListener = createMock(InterfaceListener.class);
    deviceService.addListener(deviceListener);
    setUpInterfaceService();
    interfaceService = new InternalInterfaceService();
    interfaceService.addListener(interfaceListener);
    networkConfigService = new TestNetworkConfigService();
    networkConfigService.addListener(networkConfigListener);
    flowObjectiveService = createMock(FlowObjectiveService.class);
    applicationService = createNiceMock(ApplicationService.class);
    replay(applicationService);
    setUpFlowObjectiveService();
    controlPlaneRedirectManager.coreService = coreService;
    controlPlaneRedirectManager.flowObjectiveService = flowObjectiveService;
    controlPlaneRedirectManager.networkConfigService = networkConfigService;
    controlPlaneRedirectManager.interfaceService = interfaceService;
    controlPlaneRedirectManager.deviceService = deviceService;
    controlPlaneRedirectManager.hostService = createNiceMock(HostService.class);
    controlPlaneRedirectManager.mastershipService = mastershipService;
    controlPlaneRedirectManager.applicationService = applicationService;
    controlPlaneRedirectManager.activate(new ComponentContextAdapter());
    verify(flowObjectiveService);
}
Also used : HostService(org.onosproject.net.host.HostService) DeviceListener(org.onosproject.net.device.DeviceListener) ComponentContextAdapter(org.onlab.osgi.ComponentContextAdapter) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) InterfaceListener(org.onosproject.net.intf.InterfaceListener) ApplicationService(org.onosproject.app.ApplicationService) Before(org.junit.Before)

Example 2 with DeviceListener

use of org.onosproject.net.device.DeviceListener in project onos by opennetworkinglab.

the class ArtemisDeaggregatorImpl method activate.

@Activate
protected void activate() {
    rulesInstalled = false;
    // FIXME: add other type of BGP Speakers when Dynamic Configuration is available
    bgpSpeakers.add(new QuaggaBgpSpeakers(bgpInfoService));
    moasServer = new MoasServerController();
    moasServer.start(moasAgent, packetProcessor);
    deviceService.addListener(deviceListener);
    appId = coreService.getAppId("org.onosproject.artemis");
    // enable OVSDB for the switches that we will install the GRE tunnel
    artemisService.getConfig().ifPresent(config -> config.moasInfo().getTunnelPoints().forEach(tunnelPoint -> ovsdbController.connect(tunnelPoint.getOvsdbIp(), TpPort.tpPort(6640))));
    artemisService.addListener(artemisEventListener);
    log.info("Artemis Deaggregator Service Started");
/*
        log.info("interfaces {}", interfaceService.getInterfaces());

        [{
         "name": "",
         "connectPoint": "of:000000000000000a/2",
         "ipAddresses": "[1.1.1.1/30]",
         "macAddress": "00:00:00:00:00:01"
        },
        {
         "name": "",
         "connectPoint": "of:000000000000000a/3",
         "ipAddresses": "[10.0.0.1/8]",
         "macAddress": "00:00:00:00:00:01"
        }]
        */
}
Also used : CoreService(org.onosproject.core.CoreService) ArtemisService(org.onosproject.artemis.ArtemisService) PortNumber(org.onosproject.net.PortNumber) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ArtemisEventListener(org.onosproject.artemis.ArtemisEventListener) BgpInfoService(org.onosproject.routing.bgp.BgpInfoService) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) Unpooled(io.netty.buffer.Unpooled) ArtemisMoasAgent(org.onosproject.artemis.ArtemisMoasAgent) JSONObject(org.json.JSONObject) FlowRuleService(org.onosproject.net.flow.FlowRuleService) OvsdbController(org.onosproject.ovsdb.controller.OvsdbController) Port(org.onosproject.net.Port) Map(java.util.Map) CharsetUtil(io.netty.util.CharsetUtil) ApplicationId(org.onosproject.core.ApplicationId) ArtemisPacketProcessor(org.onosproject.artemis.ArtemisPacketProcessor) TYPE_IPV4(org.onlab.packet.Ethernet.TYPE_IPV4) MoasClientController(org.onosproject.artemis.impl.moas.MoasClientController) Deactivate(org.osgi.service.component.annotations.Deactivate) BgpSpeakers(org.onosproject.artemis.BgpSpeakers) Set(java.util.Set) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Sets(com.google.common.collect.Sets) DeviceEvent(org.onosproject.net.device.DeviceEvent) Optional(java.util.Optional) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) QuaggaBgpSpeakers(org.onosproject.artemis.impl.bgpspeakers.QuaggaBgpSpeakers) MoasServerController(org.onosproject.artemis.impl.moas.MoasServerController) InterfaceService(org.onosproject.net.intf.InterfaceService) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ByteBuf(io.netty.buffer.ByteBuf) ArtemisDeaggregator(org.onosproject.artemis.ArtemisDeaggregator) OvsdbInterface(org.onosproject.ovsdb.controller.OvsdbInterface) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) TpPort(org.onlab.packet.TpPort) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) DeviceListener(org.onosproject.net.device.DeviceListener) Logger(org.slf4j.Logger) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ArtemisMessage(org.onosproject.artemis.impl.objects.ArtemisMessage) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) Maps(com.google.common.collect.Maps) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) OvsdbBridge(org.onosproject.ovsdb.controller.OvsdbBridge) OvsdbClientService(org.onosproject.ovsdb.controller.OvsdbClientService) Reference(org.osgi.service.component.annotations.Reference) MoasServerController(org.onosproject.artemis.impl.moas.MoasServerController) QuaggaBgpSpeakers(org.onosproject.artemis.impl.bgpspeakers.QuaggaBgpSpeakers) Activate(org.osgi.service.component.annotations.Activate)

Example 3 with DeviceListener

use of org.onosproject.net.device.DeviceListener in project onos by opennetworkinglab.

the class FlowObjectiveManagerTest method deviceUpEvent.

/**
 * Tests receipt of a device up event.
 *
 * @throws TestUtilsException if lookup of a field fails
 */
@Test
public void deviceUpEvent() throws TestUtilsException {
    TrafficSelector selector = DefaultTrafficSelector.emptySelector();
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, d2);
    DeviceListener listener = TestUtils.getField(manager, "deviceListener");
    assertThat(listener, notNullValue());
    listener.event(event);
    ForwardingObjective forward = DefaultForwardingObjective.builder().fromApp(NetTestTools.APP_ID).withFlag(ForwardingObjective.Flag.SPECIFIC).withSelector(selector).withTreatment(treatment).makePermanent().add();
    manager.forward(id2, forward);
    // new device should have an objective now
    TestTools.assertAfter(RETRY_MS, () -> assertThat(forwardingObjectives, hasSize(1)));
    assertThat(forwardingObjectives, hasItem("of:d2"));
    assertThat(filteringObjectives, hasSize(0));
    assertThat(nextObjectives, hasSize(0));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DeviceListener(org.onosproject.net.device.DeviceListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) Test(org.junit.Test)

Aggregations

DeviceListener (org.onosproject.net.device.DeviceListener)3 DeviceEvent (org.onosproject.net.device.DeviceEvent)2 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)2 FlowObjectiveService (org.onosproject.net.flowobjective.FlowObjectiveService)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Maps (com.google.common.collect.Maps)1 Sets (com.google.common.collect.Sets)1 ByteBuf (io.netty.buffer.ByteBuf)1 Unpooled (io.netty.buffer.Unpooled)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 CharsetUtil (io.netty.util.CharsetUtil)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 JSONObject (org.json.JSONObject)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ComponentContextAdapter (org.onlab.osgi.ComponentContextAdapter)1 TYPE_IPV4 (org.onlab.packet.Ethernet.TYPE_IPV4)1