Search in sources :

Example 61 with Link

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

the class ConfigureLinkCommand method doExecute.

@Override
protected void doExecute() {
    DeviceService deviceService = get(DeviceService.class);
    NetworkConfigService netCfgService = get(NetworkConfigService.class);
    ConnectPoint srcCp = ConnectPoint.deviceConnectPoint(src);
    if (deviceService.getPort(srcCp) == null) {
        print("[ERROR] %s does not exist", srcCp);
        return;
    }
    ConnectPoint dstCp = ConnectPoint.deviceConnectPoint(dst);
    if (deviceService.getPort(dstCp) == null) {
        print("[ERROR] %s does not exist", dstCp);
        return;
    }
    LinkKey link = linkKey(srcCp, dstCp);
    if (remove) {
        netCfgService.removeConfig(link, BasicLinkConfig.class);
        return;
    }
    Long bw = Optional.ofNullable(bandwidth).map(Long::valueOf).orElse(null);
    Link.Type linkType = Link.Type.valueOf(type);
    BasicLinkConfig cfg = netCfgService.addConfig(link, BasicLinkConfig.class);
    cfg.isAllowed(!disallow);
    cfg.isBidirectional(!isUniDi);
    cfg.type(linkType);
    if (bw != null) {
        cfg.bandwidth(bw);
    }
    cfg.apply();
}
Also used : LinkKey(org.onosproject.net.LinkKey) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) BasicLinkConfig(org.onosproject.net.config.basics.BasicLinkConfig)

Example 62 with Link

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

the class LinkEventTest method withoutTime.

@Test
public void withoutTime() {
    Link link = createLink();
    long before = System.currentTimeMillis();
    LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link);
    long after = System.currentTimeMillis();
    validateEvent(event, LinkEvent.Type.LINK_ADDED, link, before, after);
}
Also used : DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 63 with Link

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

the class LinkEventTest method withTime.

@Test
public void withTime() {
    Link link = createLink();
    LinkEvent event = new LinkEvent(LinkEvent.Type.LINK_ADDED, link, 123L);
    validateEvent(event, LinkEvent.Type.LINK_ADDED, link, 123L);
}
Also used : DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) AbstractEventTest(org.onosproject.event.AbstractEventTest) Test(org.junit.Test)

Example 64 with Link

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

the class DefaultTopologyTest method setUp.

@Before
public void setUp() {
    long now = System.currentTimeMillis();
    Set<Device> devices = of(device("1"), device("2"), device("3"), device("4"), device("5"));
    Set<Link> links = of(link("1", 1, "2", 1), link("2", 1, "1", 1), link("3", 2, "2", 2), link("2", 2, "3", 2), link("1", 3, "4", 3), link("4", 3, "1", 3), link("3", 4, "4", 4), link("4", 4, "3", 4));
    GraphDescription graphDescription = new DefaultGraphDescription(now, System.currentTimeMillis(), devices, links);
    dt = new DefaultTopology(PID, graphDescription);
    assertEquals("incorrect supplier", PID, dt.providerId());
    assertEquals("incorrect time", now, dt.time());
    assertEquals("incorrect device count", 5, dt.deviceCount());
    assertEquals("incorrect link count", 8, dt.linkCount());
    assertEquals("incorrect cluster count", 2, dt.clusterCount());
    assertEquals("incorrect broadcast set size", 6, dt.broadcastSetSize(C0));
    assertEquals("incorrect root node", V1, dt.getCluster(C0).root());
    assertEquals("incorrect root node", V5, dt.getCluster(C1).root());
}
Also used : DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultGraphDescription(org.onosproject.net.topology.DefaultGraphDescription) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GraphDescription(org.onosproject.net.topology.GraphDescription) DefaultGraphDescription(org.onosproject.net.topology.DefaultGraphDescription) Before(org.junit.Before)

Example 65 with Link

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

the class LinkManagerTest method getLinks.

@Test
public void getLinks() {
    Link l1 = addLink(DID1, P1, DID2, P2, DIRECT);
    Link l2 = addLink(DID2, P2, DID1, P1, DIRECT);
    Link l3 = addLink(DID3, P3, DID2, P1, DIRECT);
    Link l4 = addLink(DID2, P1, DID3, P3, DIRECT);
    assertEquals("incorrect link count", 4, service.getLinkCount());
    Set<Link> links = service.getLinks(cp(DID1, P1));
    assertEquals("incorrect links", ImmutableSet.of(l1, l2), links);
    links = service.getEgressLinks(cp(DID1, P1));
    assertEquals("incorrect links", ImmutableSet.of(l1), links);
    links = service.getIngressLinks(cp(DID1, P1));
    assertEquals("incorrect links", ImmutableSet.of(l2), links);
    links = service.getDeviceLinks(DID2);
    assertEquals("incorrect links", ImmutableSet.of(l1, l2, l3, l4), links);
    links = service.getDeviceLinks(DID3);
    assertEquals("incorrect links", ImmutableSet.of(l3, l4), links);
    links = service.getDeviceEgressLinks(DID2);
    assertEquals("incorrect links", ImmutableSet.of(l2, l4), links);
    links = service.getDeviceIngressLinks(DID2);
    assertEquals("incorrect links", ImmutableSet.of(l1, l3), links);
}
Also used : 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