Search in sources :

Example 26 with PortDescription

use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.

the class OpenFlowDeviceProviderTest method switchChanged.

// test receiving features reply
@Test
public void switchChanged() {
    controller.listener.switchChanged(DPID1);
    Collection<PortDescription> updatedDescr = registry.ports.values();
    for (PortDescription pd : updatedDescr) {
        assertNotNull("Switch change not handled by the provider service", pd);
    }
}
Also used : PortDescription(org.onosproject.net.device.PortDescription) Test(org.junit.Test)

Example 27 with PortDescription

use of org.onosproject.net.device.PortDescription 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 28 with PortDescription

use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.

the class OpticalPortOperatorTest method testEmptyConfig.

@Test
public void testEmptyConfig() {
    opc.portType(Port.Type.ODUCLT).portNumberName(PORT_NUMBER);
    PortDescription res;
    res = oper.combine(CP, N_DESC);
    assertEquals("Configured port name expected", DESC_PORT_NAME, res.portNumber().name());
    assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
}
Also used : OduCltPortHelper.oduCltPortDescription(org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription) PortDescription(org.onosproject.net.device.PortDescription) Test(org.junit.Test)

Example 29 with PortDescription

use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.

the class OpticalPortOperatorTest method testConfigPortName.

@Test
public void testConfigPortName() {
    opc.portType(Port.Type.ODUCLT).portNumberName(PORT_NUMBER).portName(CFG_PORT_NAME);
    PortDescription res;
    // full desc + opc with name
    res = oper.combine(CP, N_DESC);
    assertEquals("Configured port name expected", CFG_PORT_NAME, res.portNumber().name());
    assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
    res = oper.combine(CP, U_DESC);
    assertEquals("Configured port name expected", CFG_PORT_NAME, res.portNumber().name());
    assertEquals(DESC_STATIC_PORT, res.annotations().value(AnnotationKeys.STATIC_PORT));
}
Also used : OduCltPortHelper.oduCltPortDescription(org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription) PortDescription(org.onosproject.net.device.PortDescription) Test(org.junit.Test)

Example 30 with PortDescription

use of org.onosproject.net.device.PortDescription in project onos by opennetworkinglab.

the class SimpleDeviceStoreTest method testGetPort.

@Test
public final void testGetPort() {
    putDevice(DID1, SW1);
    putDevice(DID2, SW1);
    List<PortDescription> pds = Arrays.asList(DefaultPortDescription.builder().withPortNumber(P1).isEnabled(true).build(), DefaultPortDescription.builder().withPortNumber(P2).isEnabled(false).build());
    deviceStore.updatePorts(PID, DID1, pds);
    Port port1 = deviceStore.getPort(DID1, P1);
    assertEquals(P1, port1.number());
    assertTrue("Port is enabled", port1.isEnabled());
    Port port2 = deviceStore.getPort(DID1, P2);
    assertEquals(P2, port2.number());
    assertFalse("Port is disabled", port2.isEnabled());
    Port port3 = deviceStore.getPort(DID1, P3);
    assertNull("P3 not expected", port3);
}
Also used : Port(org.onosproject.net.Port) PortDescription(org.onosproject.net.device.PortDescription) DefaultPortDescription(org.onosproject.net.device.DefaultPortDescription) Test(org.junit.Test)

Aggregations

PortDescription (org.onosproject.net.device.PortDescription)81 DefaultPortDescription (org.onosproject.net.device.DefaultPortDescription)41 Test (org.junit.Test)25 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)25 PortNumber (org.onosproject.net.PortNumber)24 DeviceId (org.onosproject.net.DeviceId)23 ArrayList (java.util.ArrayList)22 Port (org.onosproject.net.Port)22 DeviceEvent (org.onosproject.net.device.DeviceEvent)14 ProviderId (org.onosproject.net.provider.ProviderId)13 Device (org.onosproject.net.Device)12 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)11 DefaultPort (org.onosproject.net.DefaultPort)9 DeviceService (org.onosproject.net.device.DeviceService)9 NetconfSession (org.onosproject.netconf.NetconfSession)8 IOException (java.io.IOException)7 HashMap (java.util.HashMap)7 OduCltPortHelper.oduCltPortDescription (org.onosproject.net.optical.device.OduCltPortHelper.oduCltPortDescription)7 OmsPortHelper.omsPortDescription (org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription)7 OchPortHelper.ochPortDescription (org.onosproject.net.optical.device.OchPortHelper.ochPortDescription)6