Search in sources :

Example 16 with VirtualLink

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

the class VirtualNetworkManagerTest method setupVirtualNetworkTopology.

/**
 * Method to create the virtual network for {@code tenantIdValue} for further testing.
 */
private VirtualNetwork setupVirtualNetworkTopology(String tenantIdValue) {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue));
    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);
    VirtualDevice virtualDevice5 = manager.createVirtualDevice(virtualNetwork.id(), DID5);
    ConnectPoint cp1 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(1), cp1);
    ConnectPoint cp2 = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), PortNumber.portNumber(2), cp2);
    ConnectPoint cp3 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(3));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(3), cp3);
    ConnectPoint cp4 = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(4));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), PortNumber.portNumber(4), cp4);
    ConnectPoint 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);
    ConnectPoint cp8 = new ConnectPoint(virtualDevice4.id(), PortNumber.portNumber(8));
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice4.id(), PortNumber.portNumber(8), cp8);
    ConnectPoint 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);
    topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    topologyProvider = new DefaultVirtualNetworkProvider();
    try {
        TestUtils.setField(topologyProvider, "topologyService", topologyService);
    } catch (TestUtils.TestUtilsException e) {
        e.printStackTrace();
    }
    return virtualNetwork;
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) TestUtils(org.onlab.junit.TestUtils) DefaultVirtualNetworkProvider(org.onosproject.incubator.net.virtual.impl.provider.DefaultVirtualNetworkProvider) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) TopologyService(org.onosproject.net.topology.TopologyService)

Example 17 with VirtualLink

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

the class VirtualNetworkManagerTest method testAddRemoveVirtualLink.

/**
 * Tests add and remove of virtual links.
 */
@Test
public void testAddRemoveVirtualLink() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice srcVirtualDevice = manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    VirtualDevice dstVirtualDevice = manager.createVirtualDevice(virtualNetwork1.id(), DID2);
    ConnectPoint src = new ConnectPoint(srcVirtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork1.id(), src.deviceId(), src.port(), new ConnectPoint(srcVirtualDevice.id(), src.port()));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork1.id(), dst.deviceId(), dst.port(), new ConnectPoint(dstVirtualDevice.id(), dst.port()));
    manager.createVirtualLink(virtualNetwork1.id(), src, dst);
    manager.createVirtualLink(virtualNetwork1.id(), dst, src);
    Set<VirtualLink> virtualLinks = manager.getVirtualLinks(virtualNetwork1.id());
    assertNotNull("The virtual link set should not be null", virtualLinks);
    assertEquals("The virtual link set size did not match.", 2, virtualLinks.size());
    for (VirtualLink virtualLink : virtualLinks) {
        manager.removeVirtualLink(virtualLink.networkId(), virtualLink.src(), virtualLink.dst());
        // attempt to remove the same virtual link again.
        manager.removeVirtualLink(virtualLink.networkId(), virtualLink.src(), virtualLink.dst());
    }
    virtualLinks = manager.getVirtualLinks(virtualNetwork1.id());
    assertTrue("The virtual link set should be empty.", virtualLinks.isEmpty());
    // Add/remove the virtual link again.
    VirtualLink virtualLink = manager.createVirtualLink(virtualNetwork1.id(), src, dst);
    manager.removeVirtualLink(virtualLink.networkId(), virtualLink.src(), virtualLink.dst());
    virtualLinks = manager.getVirtualLinks(virtualNetwork1.id());
    assertTrue("The virtual link set should be empty.", virtualLinks.isEmpty());
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) 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) Test(org.junit.Test)

Example 18 with VirtualLink

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

the class VirtualNetworkManagerTest method testRemoveAllElements.

/**
 * Tests when a virtual element is removed, all the other elements depending on it are also removed.
 */
@Test
public void testRemoveAllElements() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork1.id(), DID2);
    ConnectPoint src = new ConnectPoint(virtualDevice1.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork1.id(), src.deviceId(), src.port(), new ConnectPoint(PHYDID1, PortNumber.portNumber(1)));
    ConnectPoint dst = new ConnectPoint(virtualDevice2.id(), PortNumber.portNumber(2));
    manager.createVirtualPort(virtualNetwork1.id(), dst.deviceId(), dst.port(), new ConnectPoint(PHYDID2, PortNumber.portNumber(2)));
    manager.createVirtualLink(virtualNetwork1.id(), src, dst);
    manager.createVirtualLink(virtualNetwork1.id(), dst, src);
    ConnectPoint hostCp = new ConnectPoint(DID1, P1);
    manager.createVirtualPort(virtualNetwork1.id(), hostCp.deviceId(), hostCp.port(), new ConnectPoint(PHYDID1, P1));
    manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    // When a virtual port is removed, all virtual links connected to it should also be removed.
    manager.removeVirtualPort(virtualNetwork1.id(), DID1, PortNumber.portNumber(1));
    Set<VirtualLink> virtualLinks = manager.getVirtualLinks(virtualNetwork1.id());
    assertTrue("The virtual link set should be empty.", virtualLinks.isEmpty());
    // When a virtual port is removed, all virtual hosts located to it should also be removed.
    manager.removeVirtualPort(virtualNetwork1.id(), DID1, P1);
    Set<VirtualHost> virtualHosts = manager.getVirtualHosts(virtualNetwork1.id());
    assertTrue("The virtual host set should be empty.", virtualHosts.isEmpty());
    manager.createVirtualPort(virtualNetwork1.id(), src.deviceId(), src.port(), new ConnectPoint(PHYDID1, PortNumber.portNumber(1)));
    manager.createVirtualLink(virtualNetwork1.id(), src, dst);
    manager.createVirtualLink(virtualNetwork1.id(), dst, src);
    manager.createVirtualPort(virtualNetwork1.id(), hostCp.deviceId(), hostCp.port(), new ConnectPoint(PHYDID1, P1));
    manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    // When a virtual device is removed, all virtual ports, hosts and links depended on it should also be removed.
    manager.removeVirtualDevice(virtualNetwork1.id(), DID1);
    Set<VirtualPort> virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), DID1);
    assertTrue("The virtual port set of DID1 should be empty", virtualPorts.isEmpty());
    virtualLinks = manager.getVirtualLinks(virtualNetwork1.id());
    assertTrue("The virtual link set should be empty.", virtualLinks.isEmpty());
    virtualHosts = manager.getVirtualHosts(virtualNetwork1.id());
    assertTrue("The virtual host set should be empty.", virtualHosts.isEmpty());
    // When a tenantId is removed, all the virtual networks belonging to it should also be removed.
    manager.unregisterTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    Set<VirtualNetwork> virtualNetworks = manager.getVirtualNetworks(TenantId.tenantId(tenantIdValue1));
    assertNotNull("The virtual network set should not be null", virtualNetworks);
    assertTrue("The virtual network set should be empty.", virtualNetworks.isEmpty());
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) VirtualHost(org.onosproject.incubator.net.virtual.VirtualHost) ConnectPoint(org.onosproject.net.ConnectPoint) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Test(org.junit.Test)

Example 19 with VirtualLink

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

the class DistributedVirtualNetworkStore method addLink.

@Override
public VirtualLink addLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, Link.State state, TunnelId realizedBy) {
    checkState(networkExists(networkId), "The network has not been added.");
    checkState(virtualPortExists(networkId, src.deviceId(), src.port()), "The source virtual port has not been added.");
    checkState(virtualPortExists(networkId, dst.deviceId(), dst.port()), "The destination virtual port has not been added.");
    Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(networkId);
    if (virtualLinkSet == null) {
        virtualLinkSet = new HashSet<>();
    }
    // validate that the link does not already exist in this network
    checkState(getLink(networkId, src, dst) == null, "The virtual link already exists");
    checkState(getLink(networkId, src, null) == null, "The source connection point has been used by another link");
    checkState(getLink(networkId, null, dst) == null, "The destination connection point has been used by another link");
    VirtualLink virtualLink = DefaultVirtualLink.builder().networkId(networkId).src(src).dst(dst).state(state).tunnelId(realizedBy).build();
    virtualLinkSet.add(virtualLink);
    networkIdVirtualLinkSetMap.put(networkId, virtualLinkSet);
    return virtualLink;
}
Also used : DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink)

Example 20 with VirtualLink

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

the class DistributedVirtualNetworkStore method getLink.

@Override
public VirtualLink getLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst) {
    Set<VirtualLink> virtualLinkSet = networkIdVirtualLinkSetMap.get(networkId);
    if (virtualLinkSet == null) {
        return null;
    }
    VirtualLink virtualLink = null;
    for (VirtualLink link : virtualLinkSet) {
        if (src == null && link.dst().equals(dst)) {
            virtualLink = link;
            break;
        } else if (dst == null && link.src().equals(src)) {
            virtualLink = link;
            break;
        } else if (link.src().equals(src) && link.dst().equals(dst)) {
            virtualLink = link;
            break;
        }
    }
    return virtualLink;
}
Also used : DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) 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