use of org.onosproject.net.optical.config.OpticalPortConfig 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;
}
Aggregations