Search in sources :

Example 6 with VirtualDevice

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

the class VirtualNetworkIntentManagerTest 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);
    Port port1 = new DefaultPort(virtualDevice1, PortNumber.portNumber(1), true);
    cp1 = new ConnectPoint(virtualDevice1.id(), port1.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port1.number(), cp1);
    Port port2 = new DefaultPort(virtualDevice1, PortNumber.portNumber(2), true);
    cp2 = new ConnectPoint(virtualDevice1.id(), port2.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice1.id(), port2.number(), cp2);
    Port port3 = new DefaultPort(virtualDevice2, PortNumber.portNumber(3), true);
    cp3 = new ConnectPoint(virtualDevice2.id(), port3.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port3.number(), cp3);
    Port port4 = new DefaultPort(virtualDevice2, PortNumber.portNumber(4), true);
    cp4 = new ConnectPoint(virtualDevice2.id(), port4.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice2.id(), port4.number(), cp4);
    Port port5 = new DefaultPort(virtualDevice3, PortNumber.portNumber(5), true);
    cp5 = new ConnectPoint(virtualDevice3.id(), port5.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port5.number(), cp5);
    Port port6 = new DefaultPort(virtualDevice3, PortNumber.portNumber(6), true);
    cp6 = new ConnectPoint(virtualDevice3.id(), port6.number());
    manager.createVirtualPort(virtualNetwork.id(), virtualDevice3.id(), port6.number(), cp6);
    link1 = manager.createVirtualLink(virtualNetwork.id(), cp1, cp3);
    virtualNetworkManagerStore.updateLink(link1, link1.tunnelId(), Link.State.ACTIVE);
    link2 = manager.createVirtualLink(virtualNetwork.id(), cp3, cp1);
    virtualNetworkManagerStore.updateLink(link2, link2.tunnelId(), Link.State.ACTIVE);
    link3 = manager.createVirtualLink(virtualNetwork.id(), cp4, cp5);
    virtualNetworkManagerStore.updateLink(link3, link3.tunnelId(), Link.State.ACTIVE);
    link4 = manager.createVirtualLink(virtualNetwork.id(), cp5, cp4);
    virtualNetworkManagerStore.updateLink(link4, link4.tunnelId(), Link.State.ACTIVE);
    vnetIntentService = new VirtualNetworkIntentManager(manager, virtualNetwork.id());
    vnetIntentService.intentStore = intentStore;
    return virtualNetwork;
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) Port(org.onosproject.net.Port) DefaultPort(org.onosproject.net.DefaultPort) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultPort(org.onosproject.net.DefaultPort)

Example 7 with VirtualDevice

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

the class VirtualNetworkLinkManagerTest method testGetLinkByNullDst.

/**
 * Tests the getLink() method using a null dst connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetLinkByNullDst() {
    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));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualLink(virtualNetwork.id(), src, dst);
    manager.createVirtualLink(virtualNetwork.id(), dst, src);
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getLink() method with a null dst connect point.
    linkService.getLink(src, null);
}
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) Test(org.junit.Test)

Example 8 with VirtualDevice

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

the class VirtualNetworkLinkManagerTest method testGetLinkByNullSrc.

/**
 * Tests the getLink() method using a null src connect point.
 */
@Test(expected = NullPointerException.class)
public void testGetLinkByNullSrc() {
    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));
    ConnectPoint dst = new ConnectPoint(dstVirtualDevice.id(), PortNumber.portNumber(2));
    manager.createVirtualLink(virtualNetwork.id(), src, dst);
    manager.createVirtualLink(virtualNetwork.id(), dst, src);
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);
    // test the getLink() method with a null src connect point.
    linkService.getLink(null, dst);
}
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) Test(org.junit.Test)

Example 9 with VirtualDevice

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

the class VirtualNetworkManagerTest method testGetPhysicalDevices.

/**
 * Tests getting a collection of physical device identifier corresponding to
 * the specified virtual device.
 */
@Test
public void testGetPhysicalDevices() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    manager.registerTenantId(TenantId.tenantId(tenantIdValue2));
    VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork2 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue2));
    // two virtual device in first virtual network
    VirtualDevice vDevice1InVnet1 = manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    VirtualDevice vDevice2InVnet1 = manager.createVirtualDevice(virtualNetwork1.id(), DID2);
    // Two virtual device in second virtual network
    VirtualDevice vDevice1InVnet2 = manager.createVirtualDevice(virtualNetwork2.id(), DID1);
    VirtualDevice vDevice2InVnet2 = manager.createVirtualDevice(virtualNetwork2.id(), DID2);
    // Connection Point from each physical device
    // Virtual network 1
    ConnectPoint cp1InVnet1 = new ConnectPoint(PHYDID1, PortNumber.portNumber(10));
    ConnectPoint cp2InVnet1 = new ConnectPoint(PHYDID2, PortNumber.portNumber(20));
    ConnectPoint cp3InVnet1 = new ConnectPoint(PHYDID3, PortNumber.portNumber(30));
    ConnectPoint cp4InVnet1 = new ConnectPoint(PHYDID4, PortNumber.portNumber(40));
    // Virtual network 2
    ConnectPoint cp1InVnet2 = new ConnectPoint(PHYDID1, PortNumber.portNumber(10));
    ConnectPoint cp2InVnet2 = new ConnectPoint(PHYDID2, PortNumber.portNumber(20));
    ConnectPoint cp3InVnet2 = new ConnectPoint(PHYDID3, PortNumber.portNumber(30));
    ConnectPoint cp4InVnet2 = new ConnectPoint(PHYDID4, PortNumber.portNumber(40));
    // Make simple BigSwitch by mapping two phyDevice to one vDevice
    // First vDevice in first virtual network
    manager.createVirtualPort(virtualNetwork1.id(), vDevice1InVnet1.id(), PortNumber.portNumber(1), cp1InVnet1);
    manager.createVirtualPort(virtualNetwork1.id(), vDevice1InVnet1.id(), PortNumber.portNumber(2), cp2InVnet1);
    // Second vDevice in first virtual network
    manager.createVirtualPort(virtualNetwork1.id(), vDevice2InVnet1.id(), PortNumber.portNumber(1), cp3InVnet1);
    manager.createVirtualPort(virtualNetwork1.id(), vDevice2InVnet1.id(), PortNumber.portNumber(2), cp4InVnet1);
    // First vDevice in second virtual network
    manager.createVirtualPort(virtualNetwork2.id(), vDevice1InVnet2.id(), PortNumber.portNumber(1), cp1InVnet2);
    manager.createVirtualPort(virtualNetwork2.id(), vDevice1InVnet2.id(), PortNumber.portNumber(2), cp2InVnet2);
    // Second vDevice in second virtual network
    manager.createVirtualPort(virtualNetwork2.id(), vDevice2InVnet2.id(), PortNumber.portNumber(1), cp3InVnet2);
    manager.createVirtualPort(virtualNetwork2.id(), vDevice2InVnet2.id(), PortNumber.portNumber(2), cp4InVnet2);
    Set<DeviceId> physicalDeviceSet;
    Set<DeviceId> testSet = new HashSet<>();
    physicalDeviceSet = manager.getPhysicalDevices(virtualNetwork1.id(), vDevice1InVnet1.id());
    testSet.add(PHYDID1);
    testSet.add(PHYDID2);
    assertEquals("The physical devices 1 did not match", testSet, physicalDeviceSet);
    testSet.clear();
    physicalDeviceSet = manager.getPhysicalDevices(virtualNetwork1.id(), vDevice2InVnet1.id());
    testSet.add(PHYDID3);
    testSet.add(PHYDID4);
    assertEquals("The physical devices 2 did not match", testSet, physicalDeviceSet);
    testSet.clear();
    physicalDeviceSet = manager.getPhysicalDevices(virtualNetwork2.id(), vDevice1InVnet2.id());
    testSet.add(PHYDID1);
    testSet.add(PHYDID2);
    assertEquals("The physical devices 1 did not match", testSet, physicalDeviceSet);
    testSet.clear();
    physicalDeviceSet = manager.getPhysicalDevices(virtualNetwork2.id(), vDevice2InVnet2.id());
    testSet.add(PHYDID3);
    testSet.add(PHYDID4);
    assertEquals("The physical devices 2 did not match", testSet, physicalDeviceSet);
    testSet.clear();
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) DeviceId(org.onosproject.net.DeviceId) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 10 with VirtualDevice

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

the class VirtualNetworkManagerTest method testAddRemoveVirtualPort.

/**
 * Tests add, bind and remove of virtual ports.
 */
@Test
public void testAddRemoveVirtualPort() {
    List<VirtualNetworkEvent.Type> expectedEventTypes = new ArrayList<>();
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    expectedEventTypes.add(VirtualNetworkEvent.Type.TENANT_REGISTERED);
    VirtualNetwork virtualNetwork1 = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    expectedEventTypes.add(VirtualNetworkEvent.Type.NETWORK_ADDED);
    VirtualDevice virtualDevice = manager.createVirtualDevice(virtualNetwork1.id(), DID1);
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_DEVICE_ADDED);
    ConnectPoint cp = new ConnectPoint(virtualDevice.id(), PortNumber.portNumber(1));
    manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_ADDED);
    manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(2), cp);
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_ADDED);
    Set<VirtualPort> virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), virtualDevice.id());
    assertNotNull("The virtual port set should not be null", virtualPorts);
    assertEquals("The virtual port set size did not match.", 2, virtualPorts.size());
    virtualPorts.forEach(vp -> assertFalse("Initial virtual port state should be disabled", vp.isEnabled()));
    // verify change state of virtual port (disabled -> enabled)
    manager.updatePortState(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1), true);
    VirtualPort changedPort = getPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1));
    assertNotNull("The changed virtual port should not be null", changedPort);
    assertEquals("Virtual port state should be enabled", true, changedPort.isEnabled());
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_UPDATED);
    // verify change state of virtual port (disabled -> disabled)
    manager.updatePortState(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(2), false);
    changedPort = getPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(2));
    assertNotNull("The changed virtual port should not be null", changedPort);
    assertEquals("Virtual port state should be disabled", false, changedPort.isEnabled());
    for (VirtualPort virtualPort : virtualPorts) {
        manager.removeVirtualPort(virtualNetwork1.id(), (DeviceId) virtualPort.element().id(), virtualPort.number());
        expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_REMOVED);
        // attempt to remove the same virtual port again.
        manager.removeVirtualPort(virtualNetwork1.id(), (DeviceId) virtualPort.element().id(), virtualPort.number());
    }
    virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), virtualDevice.id());
    assertTrue("The virtual port set should be empty.", virtualPorts.isEmpty());
    // Add/remove the virtual port again.
    VirtualPort virtualPort = manager.createVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1), cp);
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_ADDED);
    ConnectPoint newCp = new ConnectPoint(DID2, PortNumber.portNumber(2));
    manager.bindVirtualPort(virtualNetwork1.id(), virtualDevice.id(), PortNumber.portNumber(1), newCp);
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_UPDATED);
    manager.removeVirtualPort(virtualNetwork1.id(), (DeviceId) virtualPort.element().id(), virtualPort.number());
    expectedEventTypes.add(VirtualNetworkEvent.Type.VIRTUAL_PORT_REMOVED);
    virtualPorts = manager.getVirtualPorts(virtualNetwork1.id(), virtualDevice.id());
    assertTrue("The virtual port set should be empty.", virtualPorts.isEmpty());
    // Validate that the events were all received in the correct order.
    validateEvents(expectedEventTypes.toArray(new VirtualNetworkEvent.Type[expectedEventTypes.size()]));
}
Also used : DefaultVirtualNetwork(org.onosproject.incubator.net.virtual.DefaultVirtualNetwork) VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) VirtualPort(org.onosproject.incubator.net.virtual.VirtualPort) ArrayList(java.util.ArrayList) VirtualDevice(org.onosproject.incubator.net.virtual.VirtualDevice) ConnectPoint(org.onosproject.net.ConnectPoint) 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