use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class BgpSpeakersListCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null) {
print("No speakers configured");
return;
}
List<BgpConfig.BgpSpeakerConfig> bgpSpeakers = Lists.newArrayList(config.bgpSpeakers());
Collections.sort(bgpSpeakers, SPEAKERS_COMPARATOR);
if (config.bgpSpeakers().isEmpty()) {
print("No speakers configured");
} else {
bgpSpeakers.forEach(s -> {
if (s.name().isPresent()) {
print(NAME_FORMAT, s.name().get(), s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
} else {
print(FORMAT, s.connectPoint().deviceId(), s.connectPoint().port(), s.vlan(), s.peers());
}
});
}
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class RemoveSpeakerCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService configService = get(NetworkConfigService.class);
CoreService coreService = get(CoreService.class);
ApplicationId appId = coreService.getAppId(RoutingService.ROUTER_APP_ID);
BgpConfig config = configService.getConfig(appId, BgpConfig.class);
if (config == null || config.bgpSpeakers().isEmpty()) {
print(NO_CONFIGURATION);
return;
}
BgpConfig.BgpSpeakerConfig speaker = config.getSpeakerWithName(name);
if (speaker == null) {
print(SPEAKER_NOT_FOUND, name);
return;
} else {
if (!speaker.peers().isEmpty()) {
// Removal not allowed when peer connections exist.
print(PEERS_EXIST, name);
return;
}
}
removeSpeakerFromConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(SPEAKER_REMOVE_SUCCESS);
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class AnnotateDeviceCommand method doExecute.
@Override
protected void doExecute() {
NetworkConfigService netcfgService = get(NetworkConfigService.class);
DeviceId deviceId = DeviceId.deviceId(uri);
if (key == null) {
print("[ERROR] Annotation key not specified.");
return;
}
DeviceAnnotationConfig cfg = netcfgService.getConfig(deviceId, DeviceAnnotationConfig.class);
if (cfg == null) {
cfg = new DeviceAnnotationConfig(deviceId);
}
if (removeCfg) {
// remove config about entry
cfg.annotation(key);
} else {
// add remove request config
cfg.annotation(key, value);
}
netcfgService.applyConfig(deviceId, DeviceAnnotationConfig.class, cfg.node());
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class AnnotatePortCommand method doExecute.
@Override
protected void doExecute() {
DeviceService deviceService = get(DeviceService.class);
NetworkConfigService netcfgService = get(NetworkConfigService.class);
ConnectPoint connectPoint = ConnectPoint.deviceConnectPoint(port);
if (deviceService.getPort(connectPoint) == null) {
print("Port %s does not exist.", port);
return;
}
if (removeCfg && key == null) {
// remove whole port annotation config
netcfgService.removeConfig(connectPoint, PortAnnotationConfig.class);
print("Annotation Config about %s removed", connectPoint);
return;
}
if (key == null) {
print("[ERROR] Annotation key not specified.");
return;
}
PortAnnotationConfig cfg = netcfgService.addConfig(connectPoint, PortAnnotationConfig.class);
if (removeCfg) {
// remove config about entry
cfg.annotation(key);
} else {
// add remove request config
cfg.annotation(key, value);
}
cfg.apply();
}
use of org.onosproject.net.config.NetworkConfigService 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();
}
Aggregations