Java Code Examples for org.onosproject.net.link.LinkService#getDeviceLinks()

The following examples show how to use org.onosproject.net.link.LinkService#getDeviceLinks() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinksWebResource.java    From onos with Apache License 2.0 5 votes vote down vote up
private Iterable<Link> getDeviceLinks(DeviceId deviceId,
                                      String direction,
                                      LinkService service) {
    Direction dir = direction != null ?
            Direction.valueOf(direction.toUpperCase()) : Direction.ALL;
    switch (dir) {
        case INGRESS:
            return service.getDeviceIngressLinks(deviceId);
        case EGRESS:
            return service.getDeviceEgressLinks(deviceId);
        default:
            return service.getDeviceLinks(deviceId);
    }
}
 
Example 2
Source File: LinksListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    LinkService service = get(LinkService.class);
    Iterable<Link> links = uri != null ?
            service.getDeviceLinks(deviceId(uri)) : service.getLinks();
    if (outputJson()) {
        print("%s", json(this, links));
    } else {
        Tools.stream(links)
            .sorted(Comparator.comparing(link -> linkKey(link).toString()))
            .forEach(link -> {
            print(linkString(link));
        });
    }
}
 
Example 3
Source File: VirtualNetworkLinkManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests querying for links using a null device identifier.
 */
@Test(expected = NullPointerException.class)
public void testGetDeviceLinksByNullId() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    LinkService linkService = manager.get(virtualNetwork.id(), LinkService.class);

    // test the getDeviceLinks() method with a null device identifier.
    linkService.getDeviceLinks(null);
}