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);
}
}
}
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();
}
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));
}
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);
}
}
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());
}
Aggregations