Search in sources :

Example 21 with VirtualLink

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

the class VirtualNetworkTopologyManagerTest method testIsLatest.

/**
 * Test isLatest() method.
 */
@Test
public void testIsLatest() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    // test the isLatest() method.
    assertTrue("This should be latest topology", topologyService.isLatest(topology));
    VirtualDevice srcVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    // test the isLatest() method where a new device has been added to the current topology.
    assertFalse("This should not be latest topology", topologyService.isLatest(topology));
    topology = topologyService.currentTopology();
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), src.deviceId(), src.port(), new ConnectPoint(srcVirtualDevice.id(), src.port()));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), dst.deviceId(), dst.port(), new ConnectPoint(dstVirtualDevice.id(), dst.port()));
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst);
    // test the isLatest() method where a new link has been added to the current topology.
    assertFalse("This should not be latest topology", topologyService.isLatest(topology));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) ConnectPoint(org.onosproject.net.ConnectPoint) TopologyService(org.onosproject.net.topology.TopologyService) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 22 with VirtualLink

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

the class VirtualNetworkTopologyManagerTest method setupVirtualNetworkTopology.

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

Example 23 with VirtualLink

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

the class VirtualNetworkLinkManagerTest method testGetLinks.

/**
 * Tests the getLinks(), getActiveLinks(), getLinkCount(), getLink(),
 * getLinks(ConnectPoint), getDeviceLinks(), getDeviceEgressLinks(), getDeviceIngressLinks(),
 * getEgressLinks(), getIngressLinks() methods.
 */
@Test
public void testGetLinks() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), src.deviceId(), src.port(), new ConnectPoint(srcVirtualDevice.id(), src.port()));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), dst.deviceId(), dst.port(), new ConnectPoint(dstVirtualDevice.id(), dst.port()));
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), src, dst);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), dst, src);
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getLinks() method
    Iterator<Link> it = linkService.getLinks().iterator();
    assertEquals("The link set size did not match.", 2, Iterators.size(it));
    // test the getActiveLinks() method where all links are INACTIVE
    Iterator<Link> it2 = linkService.getActiveLinks().iterator();
    assertEquals("The link set size did not match.", 0, Iterators.size(it2));
    // test the getActiveLinks() method where one link is ACTIVE
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    Iterator<Link> it3 = linkService.getActiveLinks().iterator();
    assertEquals("The link set size did not match.", 1, Iterators.size(it3));
    // test the getLinkCount() method
    assertEquals("The link set size did not match.", 2, linkService.getLinkCount());
    // test the getLink() method
    assertEquals("The expect link did not match.", link1, linkService.getLink(src, dst));
    assertEquals("The expect link did not match.", link2, linkService.getLink(dst, src));
    assertNotEquals("The expect link should not have matched.", link1, linkService.getLink(dst, src));
    // test the getLinks(ConnectPoint) method
    assertEquals("The link set size did not match.", 2, linkService.getLinks(src).size());
    assertEquals("The link set size did not match.", 2, linkService.getLinks(dst).size());
    ConnectPoint connectPoint = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(3));
    assertEquals("The link set size did not match.", 0, linkService.getLinks(connectPoint).size());
    // test the getDeviceLinks() method
    assertEquals("The link set size did not match.", 2, linkService.getDeviceLinks(DID1).size());
    assertEquals("The link set size did not match.", 2, linkService.getDeviceLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceLinks(DID3).size());
    // test the getDeviceEgressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getDeviceEgressLinks(DID1).size());
    assertEquals("The link set size did not match.", 1, linkService.getDeviceEgressLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceEgressLinks(DID3).size());
    // test the getDeviceIngressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getDeviceIngressLinks(DID1).size());
    assertEquals("The link set size did not match.", 1, linkService.getDeviceIngressLinks(DID2).size());
    assertEquals("The link set size did not match.", 0, linkService.getDeviceIngressLinks(DID3).size());
    // test the getEgressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getEgressLinks(src).size());
    assertEquals("The link set size did not match.", 1, linkService.getEgressLinks(dst).size());
    assertEquals("The link set size did not match.", 0, linkService.getEgressLinks(connectPoint).size());
    // test the getIngressLinks() method
    assertEquals("The link set size did not match.", 1, linkService.getIngressLinks(src).size());
    assertEquals("The link set size did not match.", 1, linkService.getIngressLinks(dst).size());
    assertEquals("The link set size did not match.", 0, linkService.getIngressLinks(connectPoint).size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) LinkService(org.onosproject.net.link.LinkService) Link(org.onosproject.net.Link) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 24 with VirtualLink

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

the class VirtualNetworkTopologyProviderTest method setupVirtualNetworkTopology.

/**
 * Method to create the virtual network for further testing.
 */
private void setupVirtualNetworkTopology() {
    virtualDevice1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    virtualDevice2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);
    virtualDevice3 = manager.createVirtualDevice(virtualNetwork.id(), DID3);
    virtualDevice4 = manager.createVirtualDevice(virtualNetwork.id(), DID4);
    virtualDevice5 = manager.createVirtualDevice(virtualNetwork.id(), DID5);
    cp1 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(1), cp1);
    cp2 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(2), cp2);
    cp3 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(3));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(3), cp3);
    cp4 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(4));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(4), cp4);
    cp5 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(5));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), PortNumber.portNumber(5), cp5);
    cp6 = new ConnectPoint(virtualDevice3.id(), PortNumber.portNumber(6));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), PortNumber.portNumber(6), cp6);
    cp7 = new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(7));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice4.id(), PortNumber.portNumber(7), cp7);
    cp8 = new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(8));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice4.id(), PortNumber.portNumber(8), cp8);
    cp9 = new ConnectPoint(virtualDevice5.id(), PortNumber.portNumber(9));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice5.id(), PortNumber.portNumber(9), cp9);
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    VirtualLink link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
    virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
    VirtualLink link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
    virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
    VirtualLink link5 = manager.createVirtualLink(virtualNetwork.id(), cp8, cp9);
    virtualNetworkManagerStore.updateLink(link5, link5.tunnelId(), Link.State.ACTIVE);
    VirtualLink link6 = manager.createVirtualLink(virtualNetwork.id(), cp9, cp8);
    virtualNetworkManagerStore.updateLink(link6, link6.tunnelId(), Link.State.ACTIVE);
    clusters = null;
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink)

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