use of org.onosproject.net.config.basics.BasicLinkConfig 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.config.basics.BasicLinkConfig in project onos by opennetworkinglab.
the class OplinkSwitchProtection method addLinkToPeer.
private void addLinkToPeer(DeviceId peerId) {
if (peerId == null) {
log.warn("PeerID is null for device {}", data().deviceId());
return;
}
ConnectPoint dstCp = new ConnectPoint(data().deviceId(), PortNumber.portNumber(VIRTUAL_PORT));
ConnectPoint srcCp = new ConnectPoint(peerId, PortNumber.portNumber(VIRTUAL_PORT));
LinkKey link = linkKey(srcCp, dstCp);
BasicLinkConfig cfg = handler().get(NetworkConfigService.class).addConfig(link, BasicLinkConfig.class);
cfg.type(Link.Type.VIRTUAL);
cfg.apply();
}
Aggregations