Search in sources :

Example 16 with DefaultLinkDescription

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));
}
Also used : DefaultAnnotations(org.onosproject.net.DefaultAnnotations) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 17 with DefaultLinkDescription

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);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) Link(org.onosproject.net.Link) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 18 with DefaultLinkDescription

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());
}
Also used : DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 19 with DefaultLinkDescription

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());
}
Also used : DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 20 with DefaultLinkDescription

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));
}
Also used : DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Aggregations

DefaultLinkDescription (org.onosproject.net.link.DefaultLinkDescription)27 ConnectPoint (org.onosproject.net.ConnectPoint)20 LinkDescription (org.onosproject.net.link.LinkDescription)11 Test (org.junit.Test)8 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)6 DeviceId (org.onosproject.net.DeviceId)6 Device (org.onosproject.net.Device)5 DeviceService (org.onosproject.net.device.DeviceService)5 HashSet (java.util.HashSet)4 Link (org.onosproject.net.Link)4 LinkEvent (org.onosproject.net.link.LinkEvent)4 NetconfController (org.onosproject.netconf.NetconfController)4 HashMap (java.util.HashMap)3 XPath (javax.xml.xpath.XPath)3 XPathExpressionException (javax.xml.xpath.XPathExpressionException)3 Type (org.onosproject.net.Link.Type)3 NetconfException (org.onosproject.netconf.NetconfException)3 NetconfSession (org.onosproject.netconf.NetconfSession)3 Node (org.w3c.dom.Node)3 NodeList (org.w3c.dom.NodeList)3