use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ConfigFlowRuleProgrammable method getFlowTableConfig.
private Optional<FlowTableConfig> getFlowTableConfig() {
NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
DeviceId did = data().deviceId();
return Optional.ofNullable(netcfg.getConfig(did, FlowTableConfig.class));
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ConfigFlowRuleProgrammable method createFlowTableConfig.
private Optional<FlowTableConfig> createFlowTableConfig() {
NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
DeviceId did = data().deviceId();
return Optional.ofNullable(netcfg.addConfig(did, FlowTableConfig.class));
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ConfigOpticalDeviceDiscovery method discoverPortDetails.
@Override
public List<PortDescription> discoverPortDetails() {
NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
DeviceId did = data().deviceId();
DeviceInjectionConfig cfg = netcfg.getConfig(did, DeviceInjectionConfig.class);
if (cfg == null) {
return ImmutableList.of();
}
String ports = cfg.ports();
// TODO: parse port format like [1-3,6] in the future
int numPorts = Integer.parseInt(ports);
List<PortDescription> portDescs = new ArrayList<>(numPorts);
for (int i = 1; i <= numPorts; ++i) {
PortNumber number = PortNumber.portNumber(i);
ConnectPoint cp = new ConnectPoint(did, number);
Optional<OpticalPortConfig> port = Optional.ofNullable(netcfg.getConfig(cp, OpticalPortConfig.class));
boolean isEnabled = true;
// default packet port speed on configured-optical device (in Mbps)
int speedFallback = 10_000;
long portSpeed = port.flatMap(OpticalPortConfig::speed).orElse(speedFallback);
Port.Type type = port.map(OpticalPortConfig::type).orElse(Port.Type.COPPER);
portDescs.add(DefaultPortDescription.builder().withPortNumber(number).isEnabled(isEnabled).type(type).portSpeed(portSpeed).build());
}
return portDescs;
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class ConfigLambdaQuery method queryLambdas.
@Override
public Set<OchSignal> queryLambdas(PortNumber port) {
NetworkConfigService netcfg = handler().get(NetworkConfigService.class);
ConnectPoint cp = new ConnectPoint(data().deviceId(), port);
LambdaConfig cfg = netcfg.getConfig(cp, LambdaConfig.class);
if (cfg == null) {
return ImmutableSet.of();
}
GridType type = cfg.gridType();
Optional<ChannelSpacing> dwdmSpacing = cfg.dwdmSpacing();
int start = cfg.slotStart();
int step = cfg.slotStep();
int end = cfg.slotEnd();
Set<OchSignal> lambdas = new LinkedHashSet<>();
for (int i = start; i <= end; i += step) {
switch(type) {
case DWDM:
lambdas.add(OchSignal.newDwdmSlot(dwdmSpacing.get(), i));
break;
case FLEX:
lambdas.add(OchSignal.newFlexGridSlot(i));
break;
case CWDM:
default:
log.warn("Unsupported grid type: {}", type);
break;
}
}
return lambdas;
}
use of org.onosproject.net.config.NetworkConfigService in project onos by opennetworkinglab.
the class AddPeerCommand method doExecute.
@Override
protected void doExecute() {
peerAddress = IpAddress.valueOf(ip);
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.isConnectedToPeer(peerAddress)) {
// Peering already exists.
return;
}
}
InterfaceService interfaceService = get(InterfaceService.class);
if (interfaceService.getMatchingInterface(peerAddress) == null) {
print(NO_INTERFACE, ip);
return;
}
addPeerToSpeakerConf(config);
configService.applyConfig(appId, BgpConfig.class, config.node());
print(PEER_ADD_SUCCESS);
}
Aggregations