Search in sources :

Example 21 with DefaultLinkDescription

use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.

the class TopologyMutationDriver method repairDevice.

/**
 * Repairs the specified device.
 *
 * @param deviceId device identifier
 */
void repairDevice(DeviceId deviceId) {
    // device IDs are expressed in hexadecimal... (use radix 16)
    int chassisId = Integer.parseInt(deviceId.uri().getSchemeSpecificPart(), 16);
    simulator.createDevice(deviceId, chassisId);
    Set<Link> links = savedLinks.remove(deviceId);
    if (links != null) {
        links.forEach(l -> linkProviderService.linkDetected(new DefaultLinkDescription(l.src(), l.dst(), DIRECT)));
    }
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 22 with DefaultLinkDescription

use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStore method createOrUpdateLinkDescription.

// Guarded by linkDescs value (=locking each Link)
private LinkDescription createOrUpdateLinkDescription(Map<ProviderId, LinkDescription> descs, ProviderId providerId, LinkDescription linkDescription) {
    // merge existing attributes and merge
    LinkDescription oldDesc = descs.get(providerId);
    LinkDescription newDesc = linkDescription;
    if (oldDesc != null) {
        // we only allow transition from INDIRECT -> DIRECT
        final Type newType;
        if (oldDesc.type() == DIRECT) {
            newType = DIRECT;
        } else {
            newType = linkDescription.type();
        }
        SparseAnnotations merged = union(oldDesc.annotations(), linkDescription.annotations());
        newDesc = new DefaultLinkDescription(linkDescription.src(), linkDescription.dst(), newType, merged);
    }
    return descs.put(providerId, newDesc);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) Type(org.onosproject.net.Link.Type) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 23 with DefaultLinkDescription

use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testCreateOrUpdateLink.

@Test
public final void testCreateOrUpdateLink() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    // add link
    LinkEvent event = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, INDIRECT));
    assertLink(DID1, P1, DID2, P2, INDIRECT, event.subject());
    assertEquals(LINK_ADDED, event.type());
    // update link type
    LinkEvent event2 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
    assertLink(DID1, P1, DID2, P2, DIRECT, event2.subject());
    assertEquals(LINK_UPDATED, event2.type());
    // no change
    LinkEvent event3 = linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, DIRECT));
    assertNull("No change event expected", event3);
}
Also used : LinkEvent(org.onosproject.net.link.LinkEvent) ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

Example 24 with DefaultLinkDescription

use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method putLink.

private void putLink(DeviceId srcId, PortNumber srcNum, DeviceId dstId, PortNumber dstNum, Type type, boolean isDurable, SparseAnnotations... annotations) {
    ConnectPoint src = new ConnectPoint(srcId, srcNum);
    ConnectPoint dst = new ConnectPoint(dstId, dstNum);
    linkStore.createOrUpdateLink(PID, new DefaultLinkDescription(src, dst, type, annotations));
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription)

Example 25 with DefaultLinkDescription

use of org.onosproject.net.link.DefaultLinkDescription in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testAncillaryVisible.

@Test
public final void testAncillaryVisible() {
    ConnectPoint src = new ConnectPoint(DID1, P1);
    ConnectPoint dst = new ConnectPoint(DID2, P2);
    // add Ancillary link
    linkStore.createOrUpdateLink(PIDA, new DefaultLinkDescription(src, dst, INDIRECT, A1));
    // Ancillary only link should not be visible
    assertEquals(1, linkStore.getLinkCount());
    assertNotNull(linkStore.getLink(src, dst));
}
Also used : ConnectPoint(org.onosproject.net.ConnectPoint) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) Test(org.junit.Test)

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