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));
}
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));
}
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));
}
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));
}
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);
}
Aggregations