Search in sources :

Example 31 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class TopologyManagerTest method validateEvents.

protected void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("wrong events received", types.length, listener.events.size());
    for (Event event : listener.events) {
        assertEquals("incorrect event type", types[i], event.type());
        i++;
    }
    listener.events.clear();
}
Also used : Event(org.onosproject.event.Event) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 32 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class VirtualNetworkManagerTest method testTopologyChanged.

/**
 * Test the topologyChanged() method.
 */
@Test
public void testTopologyChanged() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology(tenantIdValue1);
    VirtualNetworkProviderService providerService = manager.createProviderService(topologyProvider);
    // Initial setup is two clusters of devices/links.
    assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
    // Adding this link will join the two clusters together.
    List<Event> reasons = new ArrayList<>();
    VirtualLink link = manager.createVirtualLink(virtualNetwork.id(), cp6, cp7);
    virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp7, cp6);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    Topology topology = topologyService.currentTopology();
    providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
    // Validate that all links are still active.
    manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
        assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
    });
    virtualNetworkManagerStore.updateLink(link, link.tunnelId(), Link.State.INACTIVE);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.INACTIVE);
    providerService.topologyChanged(topologyProvider.getConnectPoints(topology));
    // Validate that all links are active again.
    manager.getVirtualLinks(virtualNetwork.id()).forEach(virtualLink -> {
        assertTrue("The virtual link should be active.", virtualLink.state().equals(Link.State.ACTIVE));
    });
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualNetworkProviderService(org.onosproject.incubator.net.virtual.provider.VirtualNetworkProviderService) ArrayList(java.util.ArrayList) Event(org.onosproject.event.Event) VirtualNetworkEvent(org.onosproject.incubator.net.virtual.VirtualNetworkEvent) Topology(org.onosproject.net.topology.Topology) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 33 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class KubevirtPortManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : KubevirtPortEvent(org.onosproject.kubevirtnetworking.api.KubevirtPortEvent) Event(org.onosproject.event.Event)

Example 34 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class KubevirtNodeManagerTest method validateEvents.

private void validateEvents(Enum... types) {
    int i = 0;
    assertEquals("Number of events did not match", types.length, testListener.events.size());
    for (Event event : testListener.events) {
        assertEquals("Incorrect event received", types[i], event.type());
        i++;
    }
    testListener.events.clear();
}
Also used : Event(org.onosproject.event.Event) KubevirtNodeEvent(org.onosproject.kubevirtnode.api.KubevirtNodeEvent)

Example 35 with Event

use of org.onosproject.event.Event in project onos by opennetworkinglab.

the class TopologyEventsListCommand method json.

/**
 * Produces JSON object for a topology event.
 *
 * @param mapper the JSON object mapper to use
 * @param event the topology event with the data
 * @return JSON object for the topology event
 */
private ObjectNode json(ObjectMapper mapper, Event event) {
    ObjectNode result = mapper.createObjectNode();
    result.put("time", event.time()).put("type", event.type().toString()).put("event", event.toString());
    // Add the reasons if a TopologyEvent
    if (event instanceof TopologyEvent) {
        TopologyEvent topologyEvent = (TopologyEvent) event;
        ArrayNode reasons = mapper.createArrayNode();
        for (Event reason : topologyEvent.reasons()) {
            reasons.add(json(mapper, reason));
        }
        result.set("reasons", reasons);
    }
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) TopologyEvent(org.onosproject.net.topology.TopologyEvent) TopologyEvent(org.onosproject.net.topology.TopologyEvent) Event(org.onosproject.event.Event) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode)

Aggregations

Event (org.onosproject.event.Event)47 TopologyEvent (org.onosproject.net.topology.TopologyEvent)9 DeviceEvent (org.onosproject.net.device.DeviceEvent)7 LinkEvent (org.onosproject.net.link.LinkEvent)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 HostEvent (org.onosproject.net.host.HostEvent)3 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 Map (java.util.Map)2 Set (java.util.Set)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutorService (java.util.concurrent.ExecutorService)2 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)2 Collectors (java.util.stream.Collectors)2 ClusterEvent (org.onosproject.cluster.ClusterEvent)2 MastershipEvent (org.onosproject.mastership.MastershipEvent)2 Link (org.onosproject.net.Link)2 IntentEvent (org.onosproject.net.intent.IntentEvent)2