Search in sources :

Example 21 with DefaultPort

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

the class SuppressionRulesTest method testNotSuppressedPort.

@Test
public void testNotSuppressedPort() {
    Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID);
    Port port = new DefaultPort(device, P1, true);
    assertFalse(rules.isSuppressed(port));
}
Also used : Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Port(org.onosproject.net.Port) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 22 with DefaultPort

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

the class SuppressionRulesTest method testSuppressedPortAnnotationExact.

@Test
public void testSuppressedPortAnnotationExact() {
    Annotations annotation = DefaultAnnotations.builder().set("sendLLDP", "false").build();
    Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID);
    Port port = new DefaultPort(device, P1, true, annotation);
    assertTrue(rules.isSuppressed(port));
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Port(org.onosproject.net.Port) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 23 with DefaultPort

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

the class SuppressionRulesTest method testSuppressedPortAnnotation.

@Test
public void testSuppressedPortAnnotation() {
    Annotations annotation = DefaultAnnotations.builder().set("no-lldp", "random").build();
    Device device = new DefaultDevice(PID, NON_SUPPRESSED_DID, Device.Type.SWITCH, MFR, HW, SW1, SN, CID);
    Port port = new DefaultPort(device, P1, true, annotation);
    assertTrue(rules.isSuppressed(port));
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Port(org.onosproject.net.Port) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 24 with DefaultPort

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

the class NetworkConfigLinksProviderTest method testRemovePort.

/**
 * Tests removing a port via an event.
 */
@Test
public void testRemovePort() {
    assertThat(provider.discoverers.entrySet(), hasSize(2));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_ADDED, dev3, new DefaultPort(dev3, portNumber3, true)));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
    deviceListener.event(new DeviceEvent(DeviceEvent.Type.PORT_REMOVED, dev3, new DefaultPort(dev3, portNumber3, true)));
    assertThat(provider.discoverers.entrySet(), hasSize(3));
}
Also used : DeviceEvent(org.onosproject.net.device.DeviceEvent) DefaultPort(org.onosproject.net.DefaultPort) Test(org.junit.Test)

Example 25 with DefaultPort

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

the class PortCodec method decode.

/**
 * {@inheritDoc}
 *
 * Note: Result of {@link Port#element()} returned Port object,
 *       is not a full Device object.
 *       Only it's DeviceId can be used.
 */
@Override
public Port decode(ObjectNode json, CodecContext context) {
    if (json == null || !json.isObject()) {
        return null;
    }
    DeviceId did = DeviceId.deviceId(json.get(ELEMENT).asText());
    Device device = new DummyDevice(did);
    PortNumber number = portNumber(json.get(PORT_NAME).asText());
    boolean isEnabled = json.get(IS_ENABLED).asBoolean();
    Type type = Type.valueOf(json.get(TYPE).asText().toUpperCase());
    long portSpeed = json.get(PORT_SPEED).asLong();
    Annotations annotations = extractAnnotations(json, context);
    return new DefaultPort(device, number, isEnabled, type, portSpeed, annotations);
}
Also used : Type(org.onosproject.net.Port.Type) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) PortNumber(org.onosproject.net.PortNumber) DefaultPort(org.onosproject.net.DefaultPort)

Aggregations

DefaultPort (org.onosproject.net.DefaultPort)33 Test (org.junit.Test)25 Port (org.onosproject.net.Port)21 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