Search in sources :

Example 86 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class WipeOutCommand method wipeOutLinks.

private void wipeOutLinks() {
    print("Wiping links");
    LinkAdminService linkAdminService = get(LinkAdminService.class);
    while (linkAdminService.getLinkCount() > 0) {
        try {
            for (Link link : linkAdminService.getLinks()) {
                linkAdminService.removeLinks(link.src());
                linkAdminService.removeLinks(link.dst());
            }
        } catch (Exception e) {
            log.info("Unable to wipe-out links", e);
        }
    }
}
Also used : LinkAdminService(org.onosproject.net.link.LinkAdminService) Link(org.onosproject.net.Link) TimeoutException(java.util.concurrent.TimeoutException) ExecutionException(java.util.concurrent.ExecutionException)

Example 87 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class PathListCommand method pathString.

/**
 * Produces a formatted string representing the specified path.
 *
 * @param path network path
 * @return formatted path string
 */
protected String pathString(Path path) {
    StringBuilder sb = new StringBuilder();
    for (Link link : path.links()) {
        sb.append(compactLinkString(link)).append(SEP);
    }
    sb.delete(sb.lastIndexOf(SEP), sb.length());
    sb.append("; cost=").append(path.cost());
    return sb.toString();
}
Also used : Link(org.onosproject.net.Link)

Example 88 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class AbstractPathServiceTest method testSelfPaths.

/**
 * Tests paths from a host.
 */
@Test
public void testSelfPaths() {
    HostId host = hid("12:34:56:78:90:ab/1");
    Set<Path> paths = service.getPaths(host, host, new TestWeigher());
    assertThat(paths, hasSize(1));
    Path path = paths.iterator().next();
    assertThat(path, not(nullValue()));
    assertThat(path.links(), hasSize(2));
    Link link1 = path.links().get(0);
    Link link2 = path.links().get(1);
    assertThat(link1.src(), is(link2.dst()));
    assertThat(link2.src(), is(link1.dst()));
    assertThat(link1.src().hostId(), is(host));
    assertThat(link2.dst().hostId(), is(host));
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) DefaultDisjointPath(org.onosproject.net.DefaultDisjointPath) Path(org.onosproject.net.Path) DisjointPath(org.onosproject.net.DisjointPath) HostId(org.onosproject.net.HostId) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) Test(org.junit.Test)

Example 89 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class SimpleLinkStore method createOrUpdateLink.

@Override
public LinkEvent createOrUpdateLink(ProviderId providerId, LinkDescription linkDescription) {
    LinkKey key = linkKey(linkDescription.src(), linkDescription.dst());
    Map<ProviderId, LinkDescription> descs = getOrCreateLinkDescriptions(key);
    synchronized (descs) {
        final Link oldLink = links.get(key);
        // update description
        createOrUpdateLinkDescription(descs, providerId, linkDescription);
        final Link newLink = composeLink(descs);
        if (oldLink == null) {
            return createLink(key, newLink);
        }
        return updateLink(key, oldLink, newLink);
    }
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) LinkKey(org.onosproject.net.LinkKey) DefaultLinkDescription(org.onosproject.net.link.DefaultLinkDescription) LinkDescription(org.onosproject.net.link.LinkDescription) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink)

Example 90 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class SimpleLinkStoreTest method testGetDeviceIngressLinks.

@Test
public final void testGetDeviceIngressLinks() {
    LinkKey linkId1 = LinkKey.linkKey(new ConnectPoint(DID1, P1), new ConnectPoint(DID2, P2));
    LinkKey linkId2 = LinkKey.linkKey(new ConnectPoint(DID2, P2), new ConnectPoint(DID1, P1));
    LinkKey linkId3 = LinkKey.linkKey(new ConnectPoint(DID1, P2), new ConnectPoint(DID2, P3));
    putLink(linkId1, DIRECT);
    putLink(linkId2, DIRECT);
    putLink(linkId3, DIRECT);
    // DID1,P1 => DID2,P2
    // DID2,P2 => DID1,P1
    // DID1,P2 => DID2,P3
    Set<Link> links1 = linkStore.getDeviceIngressLinks(DID2);
    assertEquals(2, links1.size());
    // check
    Set<Link> links2 = linkStore.getDeviceIngressLinks(DID1);
    assertEquals(1, links2.size());
    assertLink(linkId2, DIRECT, links2.iterator().next());
}
Also used : LinkKey(org.onosproject.net.LinkKey) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Test(org.junit.Test)

Aggregations

Link (org.onosproject.net.Link)172 ConnectPoint (org.onosproject.net.ConnectPoint)75 Test (org.junit.Test)66 DefaultLink (org.onosproject.net.DefaultLink)44 Intent (org.onosproject.net.intent.Intent)40 DeviceId (org.onosproject.net.DeviceId)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)27 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)26 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24 List (java.util.List)23 LinkKey (org.onosproject.net.LinkKey)23 Set (java.util.Set)22 DefaultPath (org.onosproject.net.DefaultPath)20 FlowRule (org.onosproject.net.flow.FlowRule)20 Collectors (java.util.stream.Collectors)19 PathIntent (org.onosproject.net.intent.PathIntent)18