use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class JuniperUtils method createBiDirLinkDescription.
/**
* Create two LinkDescriptions corresponding to the bidirectional links.
*
* @param localDevId the identity of the local device
* @param localPort the port of the local device
* @param remoteDevId the identity of the remote device
* @param remotePort the port of the remote device
* @param descs the collection to which the link descriptions
* should be added
*/
public static void createBiDirLinkDescription(DeviceId localDevId, Port localPort, DeviceId remoteDevId, Port remotePort, Set<LinkDescription> descs) {
ConnectPoint local = new ConnectPoint(localDevId, localPort.number());
ConnectPoint remote = new ConnectPoint(remoteDevId, remotePort.number());
DefaultAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.LAYER, "ETHERNET").build();
descs.add(new DefaultLinkDescription(local, remote, Link.Type.DIRECT, true, annotations));
descs.add(new DefaultLinkDescription(remote, local, Link.Type.DIRECT, true, annotations));
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class BasicLinkOperator method combine.
/**
* Generates a LinkDescription containing fields from a LinkDescription and
* a LinkConfig.
*
* @param cfg the link config entity from network config
* @param descr a LinkDescription
* @return LinkDescription based on both sources
*/
public static LinkDescription combine(BasicLinkConfig cfg, LinkDescription descr) {
if (cfg == null) {
return descr;
}
Link.Type type = descr.type();
if (cfg.isTypeConfigured()) {
if (cfg.type() != type) {
type = cfg.type();
}
}
SparseAnnotations sa = combine(cfg, descr.annotations());
return new DefaultLinkDescription(descr.src(), descr.dst(), type, sa);
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class LinkManagerTest method updateLink.
@Test
public void updateLink() {
addLink(DID1, P1, DID2, P2, DIRECT);
addLink(DID2, P2, DID1, P1, INDIRECT);
assertEquals("incorrect link count", 2, service.getLinkCount());
providerService.linkDetected(new DefaultLinkDescription(cp(DID2, P2), cp(DID1, P1), DIRECT));
validateEvents(LINK_UPDATED);
assertEquals("incorrect link count", 2, service.getLinkCount());
providerService.linkDetected(new DefaultLinkDescription(cp(DID2, P2), cp(DID1, P1), INDIRECT));
providerService.linkDetected(new DefaultLinkDescription(cp(DID2, P2), cp(DID1, P1), DIRECT));
assertEquals("no events expected", 0, listener.events.size());
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class LinkManagerTest method removeLink.
@Test
public void removeLink() {
addLink(DID1, P1, DID2, P2, DIRECT);
addLink(DID2, P2, DID1, P1, DIRECT);
assertEquals("incorrect link count", 2, service.getLinkCount());
providerService.linkVanished(new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P2), DIRECT));
validateEvents(LINK_REMOVED);
assertEquals("incorrect link count", 1, service.getLinkCount());
assertNull("link should not be found", service.getLink(cp(DID1, P1), cp(DID2, P2)));
assertNotNull("link should be found", service.getLink(cp(DID2, P2), cp(DID1, P1)));
providerService.linkVanished(new DefaultLinkDescription(cp(DID1, P1), cp(DID2, P2), DIRECT));
assertEquals("no events expected", 0, listener.events.size());
}
use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.
the class TopologyMutationDriver method repairLink.
/**
* Repairs the link between the specified end-points in both directions.
*
* @param one link endpoint
* @param two link endpoint
*/
void repairLink(ConnectPoint one, ConnectPoint two) {
LinkDescription link = new DefaultLinkDescription(one, two, DIRECT);
linkProviderService.linkDetected(link);
linkProviderService.linkDetected(reverse(link));
}
Aggregations