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