use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.
the class NetworkConfigLinksProvider method removePort.
/**
* Removes a port from the specified discovery helper.
* @param port the port
*/
private void removePort(Port port) {
if (port.element() instanceof Device) {
Device d = (Device) port.element();
LinkDiscovery ld = discoverers.get(d.id());
if (ld != null) {
ld.removePort(port.number());
}
} else {
log.warn("Attempted to remove non-Device port", port);
}
}
use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.
the class LldpLinkProviderTest method switchSuppressedByAnnotation.
/**
* Checks that links on a reconfigured switch are properly removed.
*/
@Test
public void switchSuppressedByAnnotation() {
// add device to stub DeviceService
deviceService.putDevice(device(DID3));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
assertFalse("Device not added", provider.discoverers.isEmpty());
// update device in stub DeviceService with suppression config
deviceService.putDevice(device(DID3, DefaultAnnotations.builder().set(LldpLinkProvider.NO_LLDP, "true").build()));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
// discovery on device is expected to be gone or stopped
LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
if (linkDiscovery != null) {
assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
}
}
use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.
the class LldpLinkProviderTest method switchRemove.
@Test
public void switchRemove() {
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID1));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_REMOVED, DID1));
final LinkDiscovery linkDiscovery = provider.discoverers.get(DID1);
if (linkDiscovery != null) {
// If LinkDiscovery helper is there after DEVICE_REMOVED,
// it should be stopped
assertTrue("Discoverer is not stopped", linkDiscovery.isStopped());
}
assertTrue("Device is not gone.", vanishedDpid(DID1));
}
use of org.onosproject.provider.lldpcommon.LinkDiscovery in project onos by opennetworkinglab.
the class LldpLinkProviderTest method portSuppressedByParentDeviceIdBlacklist.
/**
* Checks that discovery on reconfigured switch are properly restarted.
*/
@Test
public void portSuppressedByParentDeviceIdBlacklist() {
// / When Device is configured without suppression:OFF,
// / Port should be included for discovery
// add device in stub DeviceService without suppression configured
deviceService.putDevice(device(DID3));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_ADDED, DID3));
// non-suppressed port added to suppressed device
final long portno3 = 3L;
deviceService.putPorts(DID3, port(DID3, portno3, true));
deviceListener.event(portEvent(DeviceEvent.Type.PORT_ADDED, DID3, port(DID3, portno3, true)));
// discovery should succeed
assertFalse("Discoverer is expected to start", provider.discoverers.get(DID3).isStopped());
assertTrue("Discoverer should contain the port there", provider.discoverers.get(DID3).containsPort(portno3));
// add suppression rule for "deviceId: "of:0000000000000003""
deviceBlacklist.add(DID3);
configListener.event(new NetworkConfigEvent(Type.CONFIG_ADDED, DID3, LinkDiscoveryFromDevice.class));
// / When Device is reconfigured with suppression:ON, Port also is same
// update device in stub DeviceService with suppression configured
deviceService.putDevice(device(DID3));
// update the Port in stub DeviceService. (Port has reference to Device)
deviceService.putPorts(DID3, port(DID3, portno3, true));
deviceListener.event(deviceEvent(DeviceEvent.Type.DEVICE_UPDATED, DID3));
// discovery helper for device is expected to be gone or stopped
LinkDiscovery linkDiscovery = provider.discoverers.get(DID3);
if (linkDiscovery != null) {
assertTrue("Discovery expected to be stopped", linkDiscovery.isStopped());
}
}
Aggregations