Search in sources :

Example 11 with VirtualDevice

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

the class VirtualNetworkManagerTest method testAddRemoveVirtualHost.

/**
 * Tests add and remove of virtual hosts.
 */
@Test
public void testAddRemoveVirtualHost() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork2 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice virtualDevice1 = manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    VirtualDevice virtualDevice2 = manager.createVirtualDevice(virtualNetwork2.id(), DID2);
    ConnectPoint hostCp1 = new ConnectPoint(DID1, P1);
    ConnectPoint hostCp2 = new ConnectPoint(DID2, P2);
    manager.createVirtualPort(virtualNetwork1.id(), hostCp1.deviceId(), hostCp1.port(), new ConnectPoint(virtualDevice1.id(), hostCp1.port()));
    manager.createVirtualPort(virtualNetwork2.id(), hostCp2.deviceId(), hostCp2.port(), new ConnectPoint(virtualDevice2.id(), hostCp2.port()));
    manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    manager.createVirtualHost(virtualNetwork2.id(), HID2, MAC2, VLAN2, LOC2, IPSET2);
    Set<VirtualHost> virtualHosts1 = manager.getVirtualHosts(virtualNetwork1.id());
    assertNotNull("The virtual host set should not be null", virtualHosts1);
    assertEquals("The virtual host set size did not match.", 1, virtualHosts1.size());
    Set<VirtualHost> virtualHosts2 = manager.getVirtualHosts(virtualNetwork2.id());
    assertNotNull("The virtual host set should not be null", virtualHosts2);
    assertEquals("The virtual host set size did not match.", 1, virtualHosts2.size());
    for (VirtualHost virtualHost : virtualHosts1) {
        manager.removeVirtualHost(virtualNetwork1.id(), virtualHost.id());
        // attempt to remove the same virtual host again.
        manager.removeVirtualHost(virtualNetwork1.id(), virtualHost.id());
    }
    virtualHosts1 = manager.getVirtualHosts(virtualNetwork1.id());
    assertTrue("The virtual host set should be empty.", virtualHosts1.isEmpty());
    // Add/remove the virtual host again.
    VirtualHost virtualHost = manager.createVirtualHost(virtualNetwork1.id(), HID1, MAC1, VLAN1, LOC1, IPSET1);
    manager.removeVirtualHost(virtualHost.networkId(), virtualHost.id());
    virtualHosts1 = manager.getVirtualHosts(virtualNetwork1.id());
    assertTrue("The virtual host set should be empty.", virtualHosts1.isEmpty());
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) VirtualHost(org.onosproject.incubator.net.virtual.VirtualHost) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 12 with VirtualDevice

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

the class VirtualNetworkPathManagerTest method setupVnet.

/**
 * Creates a virtual network for further testing.
 *
 * @return virtual network
 */
private VirtualNetwork setupVnet() {
    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 cp11 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice1, 1);
    ConnectPoint cp12 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice1, 2);
    ConnectPoint cp23 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice2, 3);
    ConnectPoint cp24 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice2, 4);
    ConnectPoint cp35 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice3, 5);
    ConnectPoint cp36 = createConnectPointAndVirtualPort(virtualNetwork, virtualDevice3, 6);
    VirtualLink link1 = manager.createVirtualLink(virtualNetwork.id(), cp11, cp23);
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    VirtualLink link2 = manager.createVirtualLink(virtualNetwork.id(), cp23, cp11);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    VirtualLink link3 = manager.createVirtualLink(virtualNetwork.id(), cp24, cp35);
    virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
    VirtualLink link4 = manager.createVirtualLink(virtualNetwork.id(), cp35, cp24);
    virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
    VirtualLink link5 = manager.createVirtualLink(virtualNetwork.id(), cp12, cp36);
    virtualNetworkManagerStore.updateLink(link5, link5.tunnelId(), Link.State.ACTIVE);
    VirtualLink link6 = manager.createVirtualLink(virtualNetwork.id(), cp36, cp12);
    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 13 with VirtualDevice

use of org.onosproject.incubator.net.virtual.VirtualDevice 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 14 with VirtualDevice

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

the class VirtualNetworkTopologyManagerTest method testGetPathsUsingNullWeight.

/**
 * Test getPaths() method using a null weight.
 */
@Test(expected = NullPointerException.class)
public void testGetPathsUsingNullWeight() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
    // test the getPaths() method using a null weight.
    Set<Path> paths = topologyService.getPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), (LinkWeigher) null);
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Example 15 with VirtualDevice

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

the class VirtualNetworkTopologyManagerTest method testGetDisjointPaths.

/**
 * Test getDisjointPaths() methods.
 */
@Test
public void testGetDisjointPaths() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    TopologyService topologyService = manager.get(virtualNetwork.id(), TopologyService.class);
    Topology topology = topologyService.currentTopology();
    VirtualDevice srcVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice dstVirtualDevice = getVirtualDevice(virtualNetwork.id(), DID2);
    // test the getDisjointPaths() method.
    Set<DisjointPath> paths = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id());
    assertNotNull("The paths should not be null.", paths);
    assertEquals("The paths size did not match.", 1, paths.size());
    // test the getDisjointPaths() method using a weight.
    LinkWeigher weight = new LinkWeigherAdapter(1.0);
    Set<DisjointPath> paths1 = topologyService.getDisjointPaths(topology, srcVirtualDevice.id(), dstVirtualDevice.id(), weight);
    assertNotNull("The paths should not be null.", paths1);
    assertEquals("The paths size did not match.", 1, paths1.size());
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) LinkWeigherAdapter(org.onosproject.net.topology.LinkWeigherAdapter) LinkWeigher(org.onosproject.net.topology.LinkWeigher) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) Topology(org.onosproject.net.topology.Topology) DisjointPath(org.onosproject.net.DisjointPath) TopologyService(org.onosproject.net.topology.TopologyService) Test(org.junit.Test)

Aggregations

VirtualDevice (org.onosproject.incubator.net.virtual.VirtualDevice)51 VirtualNetwork (org.onosproject.incubator.net.virtual.VirtualNetwork)39 Test (org.junit.Test)29 ConnectPoint (org.onosproject.net.ConnectPoint)27 TopologyService (org.onosproject.net.topology.TopologyService)13 VirtualLink (org.onosproject.incubator.net.virtual.VirtualLink)12 Topology (org.onosproject.net.topology.Topology)12 DefaultVirtualNetwork (org.onosproject.incubator.net.virtual.DefaultVirtualNetwork)11 VirtualPort (org.onosproject.incubator.net.virtual.VirtualPort)9 DisjointPath (org.onosproject.net.DisjointPath)9 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)7 DeviceService (org.onosproject.net.device.DeviceService)7 HashSet (java.util.HashSet)6 DefaultVirtualDevice (org.onosproject.incubator.net.virtual.DefaultVirtualDevice)6 NetworkId (org.onosproject.incubator.net.virtual.NetworkId)6 DeviceId (org.onosproject.net.DeviceId)6 ArrayList (java.util.ArrayList)5 DefaultVirtualPort (org.onosproject.incubator.net.virtual.DefaultVirtualPort)5 VirtualHost (org.onosproject.incubator.net.virtual.VirtualHost)4 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)3