Search in sources :

Example 1 with VirtualLink

use of org.onosproject.incubator.net.virtual.VirtualLink in project onos by opennetworkinglab.

the class VirtualLinkListCommand method getSortedVirtualLinks.

/**
 * Returns the list of virtual links sorted using the device identifier.
 *
 * @return virtual link list
 */
private List<VirtualLink> getSortedVirtualLinks() {
    VirtualNetworkService service = get(VirtualNetworkService.class);
    List<VirtualLink> virtualLinks = new ArrayList<>();
    virtualLinks.addAll(service.getVirtualLinks(NetworkId.networkId(networkId)));
    return virtualLinks;
}
Also used : VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) ArrayList(java.util.ArrayList) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink)

Example 2 with VirtualLink

use of org.onosproject.incubator.net.virtual.VirtualLink in project onos by opennetworkinglab.

the class VirtualLinkCodec method decode.

@Override
public VirtualLink decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    JsonCodec<Link> codec = context.codec(Link.class);
    Link link = codec.decode(json, context);
    NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
    return DefaultVirtualLink.builder().networkId(nId).src(link.src()).dst(link.dst()).build();
}
Also used : NetworkId(org.onosproject.incubator.net.virtual.NetworkId) DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Link(org.onosproject.net.Link)

Example 3 with VirtualLink

use of org.onosproject.incubator.net.virtual.VirtualLink in project onos by opennetworkinglab.

the class VirtualLinkCodec method encode.

@Override
public ObjectNode encode(VirtualLink vLink, CodecContext context) {
    checkNotNull(vLink, NULL_OBJECT_MSG);
    ObjectNode result = context.mapper().createObjectNode().put(NETWORK_ID, vLink.networkId().toString());
    JsonCodec<Link> codec = context.codec(Link.class);
    ObjectNode linkResult = codec.encode(vLink, context);
    result.setAll(linkResult);
    return result;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Link(org.onosproject.net.Link)

Example 4 with VirtualLink

use of org.onosproject.incubator.net.virtual.VirtualLink in project onos by opennetworkinglab.

the class VirtualNetworkTestUtil method setupVirtualNetworkTopology.

/**
 * Method to create the virtual network for further testing.
 *
 * @return virtual network
 */
public static VirtualNetwork setupVirtualNetworkTopology(VirtualNetworkManager manager, TenantId tenantId) {
    manager.registerTenantId(tenantId);
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(tenantId);
    VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork.id(), VDID1);
    VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork.id(), VDID2);
    VirtualDevice virtualDevice3 = manager.createVirtualDevice(virtualNetwork.id(), VDID3);
    VirtualDevice virtualDevice4 = manager.createVirtualDevice(virtualNetwork.id(), VDID4);
    ConnectPoint vcp1 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
    ConnectPoint cp1 = new ConnectPoint(DID1, PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), vcp1.deviceId(), vcp1.port(), cp1);
    ConnectPoint vcp2 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(2));
    ConnectPoint cp2 = new ConnectPoint(DID1, PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), vcp2.deviceId(), vcp2.port(), cp2);
    ConnectPoint vcp3 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(3));
    ConnectPoint cp3 = new ConnectPoint(DID2, PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), vcp3.deviceId(), vcp3.port(), cp3);
    ConnectPoint vcp4 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(4));
    ConnectPoint cp4 = new ConnectPoint(DID2, PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), vcp4.deviceId(), vcp4.port(), cp4);
    ConnectPoint vcp5 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(5));
    ConnectPoint cp5 = new ConnectPoint(DID3, PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), vcp5.deviceId(), vcp5.port(), cp5);
    ConnectPoint vcp6 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(6));
    ConnectPoint cp6 = new ConnectPoint(DID3, PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), vcp6.deviceId(), vcp6.port(), cp6);
    DistributedVirtualNetworkStore virtualNetworkManagerStore = (DistributedVirtualNetworkStore) manager.store;
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), vcp1, vcp3);
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), vcp3, vcp1);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    VirtualLink link3 = manager.createVirtualLink(virtualNetwork.id(), vcp4, vcp5);
    virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
    VirtualLink link4 = manager.createVirtualLink(virtualNetwork.id(), vcp5, vcp4);
    virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
    VirtualLink link5 = manager.createVirtualLink(virtualNetwork.id(), vcp2, vcp6);
    virtualNetworkManagerStore.updateLink(link5, link5.tunnelId(), Link.State.ACTIVE);
    VirtualLink link6 = manager.createVirtualLink(virtualNetwork.id(), vcp6, vcp2);
    virtualNetworkManagerStore.updateLink(link6, link6.tunnelId(), Link.State.ACTIVE);
    return virtualNetwork;
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DistributedVirtualNetworkStore(org.onosproject.incubator.net.virtual.store.impl.DistributedVirtualNetworkStore) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink)

Example 5 with VirtualLink

use of org.onosproject.incubator.net.virtual.VirtualLink in project onos by opennetworkinglab.

the class VirtualNetworkTopologyProviderTest method testTopologyChanged.

/**
 * Test the topologyChanged() method.
 */
@Test
public void testTopologyChanged() {
    // 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);
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_ADDED, link));
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_ADDED, link2));
    TopologyEvent event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topologyService.currentTopology(), reasons);
    topologyProvider.topologyListener.event(event);
    // Wait for the topology changed event, and that the topologyChanged method was called.
    try {
        if (!changed.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for topology changed event.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception." + e.getMessage());
    }
    // Validate that the topology changed method received a single cluster of connect points.
    // This means that the two previous clusters have now joined into a single cluster.
    assertEquals("The cluster count did not match.", 1, this.clusters.size());
    assertEquals("The cluster count did not match.", 1, topologyService.currentTopology().clusterCount());
    // Now remove the virtual link to split it back into two clusters.
    manager.removeVirtualLink(virtualNetwork.id(), link.src(), link.dst());
    manager.removeVirtualLink(virtualNetwork.id(), link2.src(), link2.dst());
    assertEquals("The cluster count did not match.", 2, topologyService.currentTopology().clusterCount());
    reasons = new ArrayList<>();
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_REMOVED, link));
    reasons.add(new LinkEvent(LinkEvent.Type.LINK_REMOVED, link2));
    event = new TopologyEvent(TopologyEvent.Type.TOPOLOGY_CHANGED, topologyService.currentTopology(), reasons);
    topologyProvider.topologyListener.event(event);
    // Wait for the topology changed event, and that the topologyChanged method was called.
    try {
        if (!changed.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for topology changed event.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception." + e.getMessage());
    }
    // Validate that the topology changed method received two clusters of connect points.
    // This means that the single previous clusters has now split into two clusters.
    assertEquals("The cluster count did not match.", 2, this.clusters.size());
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) TopologyEvent(org.onosproject.net.topology.TopologyEvent) ArrayList(java.util.ArrayList) LinkEvent(org.onosproject.net.link.LinkEvent) Event(org.onosproject.event.Event) TopologyEvent(org.onosproject.net.topology.TopologyEvent) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Aggregations

VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)24 ConnectPoint (org.onosproject.net.ConnectPoint)11 DefaultVirtualLink (org.onosproject.incubator.net.virtual.DefaultVirtualLink)9 VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)9 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)9 Test (org.junit.Test)7 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)4 Link (org.onosproject.net.Link)4 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)3 ArrayList (java.util.ArrayList)3 Path (javax.ws.rs.Path)3 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Consumes (javax.ws.rs.Consumes)2 Produces (javax.ws.rs.Produces)2 Event (org.onosproject.event.Event)2 VirtualNetworkEvent (org.onosproject.incubator.net.virtual.VirtualNetworkEvent)2 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)2