Search in sources :

Example 1 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class OpenstackSwitchingHostProviderTest method testProcessPortRemoved.

@Test
public void testProcessPortRemoved() {
    org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
    DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
    target.portAddedHelper(addedEvent);
    org.onosproject.net.Port removedPort = new DefaultPort(DEV2, P1, true, ANNOTATIONS);
    DeviceEvent removedEvent = new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, DEV2, removedPort);
    target.portRemovedHelper(removedEvent);
    assertNull(target.hostService.getHost(HostId.hostId(HOST_MAC)));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 2 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class OpenstackSwitchingHostProviderTest method testProcessPortAddedForUpdate.

/**
 * Tests the process port added method for updating case.
 */
@Test
public void testProcessPortAddedForUpdate() {
    org.onosproject.net.Port addedPort = new DefaultPort(DEV1, P1, true, ANNOTATIONS);
    DeviceEvent addedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, addedPort);
    target.portAddedHelper(addedEvent);
    // org.onosproject.net.Port updatedPort = new DefaultPort(DEV1, P2, true, ANNOTATIONS);
    // DeviceEvent updatedEvent = new DeviceEvent(DeviceEvent.Type.PORT_ADDED, DEV1, updatedPort);
    target.portAddedHelper(addedEvent);
    HostId hostId = HostId.hostId(HOST_MAC);
    HostDescription hostDesc = new DefaultHostDescription(HOST_MAC, VlanId.NONE, new HostLocation(CP11, System.currentTimeMillis()), ImmutableSet.of(HOST_IP11), ANNOTATIONS);
    verifyHostResult(hostId, hostDesc);
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostLocation(org.onosproject.net.HostLocation) HostId(org.onosproject.net.HostId) DefaultPort(org.onosproject.net.DefaultPort) DefaultHostDescription(org.onosproject.net.host.DefaultHostDescription) HostDescription(org.onosproject.net.host.HostDescription) Test(org.junit.Test)

Example 3 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class OmsPortHelperTest method testOmsPortDescriptionCanBeConvertedToOmsPort.

@Test
public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
    PortNumber pn = PortNumber.portNumber(4900);
    boolean isEnabled = true;
    String anKey = "Base";
    String anValue = "value";
    SparseAnnotations an = DefaultAnnotations.builder().set(anKey, anValue).build();
    Frequency minF = Frequency.ofGHz(3);
    Frequency maxF = Frequency.ofGHz(33);
    Frequency grid = Frequency.ofGHz(2);
    PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
    Port port = new DefaultPort(DEV, portDescription.portNumber(), portDescription.isEnabled(), portDescription.type(), portDescription.portSpeed(), portDescription.annotations());
    Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
    assertTrue(maybeOms.isPresent());
    OmsPort oms = maybeOms.get();
    assertThat(oms.isEnabled(), is(isEnabled));
    assertThat(oms.number(), is(pn));
    assertThat(oms.annotations().value(anKey), is(anValue));
    assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
    assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
    assertThat(oms.maxFrequency(), is(maxF));
    assertThat(oms.minFrequency(), is(minF));
    assertThat(oms.grid(), is(grid));
    assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) OmsPort(org.onosproject.net.optical.OmsPort) DefaultPort(org.onosproject.net.DefaultPort) OmsPort(org.onosproject.net.optical.OmsPort) Port(org.onosproject.net.Port) Frequency(org.onlab.util.Frequency) PortDescription(org.onosproject.net.device.PortDescription) PortNumber(org.onosproject.net.PortNumber) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 4 with DefaultPort

use of org.onosproject.net.DefaultPort 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 5 with DefaultPort

use of org.onosproject.net.DefaultPort in project onos by opennetworkinglab.

the class EdgeManagerTest method testEmit.

@Test
public void testEmit() {
    byte[] arr = new byte[10];
    Device referenceDevice;
    DeviceEvent event;
    int numDevices = 10;
    int numInfraPorts = 5;
    totalPorts = 10;
    defaultPopulator(numDevices, numInfraPorts);
    for (byte byteIndex = 0; byteIndex < arr.length; byteIndex++) {
        arr[byteIndex] = byteIndex;
    }
    for (int i = 0; i < numDevices; i++) {
        referenceDevice = NetTestTools.device(Integer.toString(i));
        testDeviceManager.listener.event(new DeviceEvent(DEVICE_ADDED, referenceDevice, new DefaultPort(referenceDevice, PortNumber.portNumber(1), true)));
    }
    mgr.emitPacket(ByteBuffer.wrap(arr), Optional.empty());
    assertEquals("There were an unexpected number of emitted packets", (totalPorts - numInfraPorts) * numDevices, packets.size());
    Iterator<OutboundPacket> packetIter = packets.iterator();
    OutboundPacket packet;
    while (packetIter.hasNext()) {
        packet = packetIter.next();
        assertEquals("The packet had an incorrect payload.", arr, packet.data().array());
    }
    // Start testing emission to a specific device
    packets.clear();
    mgr.emitPacket(NetTestTools.did(Integer.toString(1)), ByteBuffer.wrap(arr), Optional.empty());
    assertEquals("Unexpected number of outbound packets were emitted.", totalPorts - numInfraPorts, packets.size());
    packetIter = packets.iterator();
    while (packetIter.hasNext()) {
        packet = packetIter.next();
        assertEquals("The packet had an incorrect payload", arr, packet.data().array());
    }
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) Device(org.onosproject.net.Device) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultPort(org.onosproject.net.DefaultPort) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Test(org.junit.Test)

Aggregations

DefaultPort (org.onosproject.net.DefaultPort)27 Test (org.junit.Test)19 Port (org.onosproject.net.Port)15 Device (org.onosproject.net.Device)12 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)10 DefaultDevice (org.onosproject.net.DefaultDevice)8 DeviceEvent (org.onosproject.net.device.DeviceEvent)8 PortNumber (org.onosproject.net.PortNumber)7 Annotations (org.onosproject.net.Annotations)6 ConnectPoint (org.onosproject.net.ConnectPoint)5 DeviceId (org.onosproject.net.DeviceId)4 ProviderId (org.onosproject.net.provider.ProviderId)4 Iterator (java.util.Iterator)3 Frequency (org.onlab.util.Frequency)3 HostId (org.onosproject.net.HostId)3 PortDescription (org.onosproject.net.device.PortDescription)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)2 Supplier (com.google.common.base.Supplier)2 Sets (com.google.common.collect.Sets)2