Committed by
Gerrit Code Review
Miscellaneous fixes for reading Linc-OE port types.
- Keep track of created PortDescriptions so that they can be replayed when configurations don't stick - Push topology configs to all cluster members (Temporary hack until Configs are made Mastership-aware) - Port type consistency for Optical ports - default to FIBER port type Change-Id: Ib2c9e2839c212d2998206bd0106490b2b38446a9
Showing
5 changed files
with
69 additions
and
47 deletions
| ... | @@ -189,6 +189,11 @@ public final class DefaultAnnotations implements SparseAnnotations { | ... | @@ -189,6 +189,11 @@ public final class DefaultAnnotations implements SparseAnnotations { |
| 189 | throw new IllegalArgumentException("Expecting HashMap instance"); | 189 | throw new IllegalArgumentException("Expecting HashMap instance"); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | + @Override | ||
| 193 | + public String toString() { | ||
| 194 | + return (map == null) ? "null" : map.toString(); | ||
| 195 | + } | ||
| 196 | + | ||
| 192 | /** | 197 | /** |
| 193 | * Facility for gradually building model annotations. | 198 | * Facility for gradually building model annotations. |
| 194 | */ | 199 | */ | ... | ... |
| ... | @@ -1023,11 +1023,12 @@ public class GossipDeviceStore | ... | @@ -1023,11 +1023,12 @@ public class GossipDeviceStore |
| 1023 | continue; | 1023 | continue; |
| 1024 | } | 1024 | } |
| 1025 | annotations = merge(annotations, otherPortDesc.value().annotations()); | 1025 | annotations = merge(annotations, otherPortDesc.value().annotations()); |
| 1026 | - switch (otherPortDesc.value().type()) { | 1026 | + PortDescription other = otherPortDesc.value(); |
| 1027 | + switch (other.type()) { | ||
| 1027 | case OMS: | 1028 | case OMS: |
| 1028 | OmsPortDescription omsPortDesc = (OmsPortDescription) otherPortDesc.value(); | 1029 | OmsPortDescription omsPortDesc = (OmsPortDescription) otherPortDesc.value(); |
| 1029 | updated = new OmsPort(device, number, isEnabled, omsPortDesc.minFrequency(), | 1030 | updated = new OmsPort(device, number, isEnabled, omsPortDesc.minFrequency(), |
| 1030 | - omsPortDesc.maxFrequency(), omsPortDesc.grid()); | 1031 | + omsPortDesc.maxFrequency(), omsPortDesc.grid(), annotations); |
| 1031 | break; | 1032 | break; |
| 1032 | case OCH: | 1033 | case OCH: |
| 1033 | OchPortDescription ochPortDesc = (OchPortDescription) otherPortDesc.value(); | 1034 | OchPortDescription ochPortDesc = (OchPortDescription) otherPortDesc.value(); |
| ... | @@ -1039,7 +1040,8 @@ public class GossipDeviceStore | ... | @@ -1039,7 +1040,8 @@ public class GossipDeviceStore |
| 1039 | updated = new OduCltPort(device, number, isEnabled, oduCltPortDesc.signalType(), annotations); | 1040 | updated = new OduCltPort(device, number, isEnabled, oduCltPortDesc.signalType(), annotations); |
| 1040 | break; | 1041 | break; |
| 1041 | default: | 1042 | default: |
| 1042 | - updated = new DefaultPort(device, number, isEnabled, annotations); | 1043 | + updated = new DefaultPort( |
| 1044 | + device, number, isEnabled, other.type(), other.portSpeed(), annotations); | ||
| 1043 | } | 1045 | } |
| 1044 | newest = otherPortDesc.timestamp(); | 1046 | newest = otherPortDesc.timestamp(); |
| 1045 | } | 1047 | } |
| ... | @@ -1047,7 +1049,10 @@ public class GossipDeviceStore | ... | @@ -1047,7 +1049,10 @@ public class GossipDeviceStore |
| 1047 | if (portDesc == null) { | 1049 | if (portDesc == null) { |
| 1048 | return updated == null ? new DefaultPort(device, number, false, annotations) : updated; | 1050 | return updated == null ? new DefaultPort(device, number, false, annotations) : updated; |
| 1049 | } | 1051 | } |
| 1050 | - return updated == null ? new DefaultPort(device, number, isEnabled, annotations) : updated; | 1052 | + PortDescription current = portDesc.value(); |
| 1053 | + return updated == null | ||
| 1054 | + ? new DefaultPort(device, number, isEnabled, current.type(), current.portSpeed(), annotations) | ||
| 1055 | + : updated; | ||
| 1051 | } | 1056 | } |
| 1052 | 1057 | ||
| 1053 | /** | 1058 | /** | ... | ... |
| ... | @@ -342,7 +342,6 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -342,7 +342,6 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 342 | if (sw.isOptical()) { | 342 | if (sw.isOptical()) { |
| 343 | OpenFlowOpticalSwitch opsw = (OpenFlowOpticalSwitch) sw; | 343 | OpenFlowOpticalSwitch opsw = (OpenFlowOpticalSwitch) sw; |
| 344 | opsw.getPortTypes().forEach(type -> { | 344 | opsw.getPortTypes().forEach(type -> { |
| 345 | - LOG.debug("ports: {}", opsw.getPortsOf(type)); | ||
| 346 | opsw.getPortsOf(type).forEach( | 345 | opsw.getPortsOf(type).forEach( |
| 347 | op -> { | 346 | op -> { |
| 348 | portDescs.add(buildPortDescription(type, (OFPortOptical) op)); | 347 | portDescs.add(buildPortDescription(type, (OFPortOptical) op)); |
| ... | @@ -398,10 +397,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -398,10 +397,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 398 | private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) { | 397 | private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) { |
| 399 | // Minimally functional fixture. This needs to be fixed as we add better support. | 398 | // Minimally functional fixture. This needs to be fixed as we add better support. |
| 400 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); | 399 | PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); |
| 400 | + | ||
| 401 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) | 401 | boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN) |
| 402 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); | 402 | && !port.getConfig().contains(OFPortConfig.PORT_DOWN); |
| 403 | SparseAnnotations annotations = makePortNameAnnotation(port.getName()); | 403 | SparseAnnotations annotations = makePortNameAnnotation(port.getName()); |
| 404 | - Port.Type type = FIBER; | ||
| 405 | 404 | ||
| 406 | if (port.getVersion() == OFVersion.OF_13 | 405 | if (port.getVersion() == OFVersion.OF_13 |
| 407 | && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) { | 406 | && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) { |
| ... | @@ -411,7 +410,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -411,7 +410,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
| 411 | // removable once 1.4+ support complete. | 410 | // removable once 1.4+ support complete. |
| 412 | LOG.debug("Unsupported optical port properties"); | 411 | LOG.debug("Unsupported optical port properties"); |
| 413 | } | 412 | } |
| 414 | - return new DefaultPortDescription(portNo, enabled, type, 0, annotations); | 413 | + return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations); |
| 415 | } | 414 | } |
| 416 | 415 | ||
| 417 | private PortDescription buildPortDescription(OFPortStatus status) { | 416 | private PortDescription buildPortDescription(OFPortStatus status) { | ... | ... |
| ... | @@ -445,12 +445,12 @@ class LINCSwitch(OpticalSwitch): | ... | @@ -445,12 +445,12 @@ class LINCSwitch(OpticalSwitch): |
| 445 | sleep(SLEEP_TIME) | 445 | sleep(SLEEP_TIME) |
| 446 | 446 | ||
| 447 | info('*** Pushing Topology.json to ONOS\n') | 447 | info('*** Pushing Topology.json to ONOS\n') |
| 448 | - output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json' % (LINCSwitch.onosDir, LINCSwitch.controllers[ 0 ].ip), shell=True) | 448 | + for index in range(len(LINCSwitch.controllers)): |
| 449 | - | 449 | + output = quietRun('%s/tools/test/bin/onos-topo-cfg %s Topology.json &' % (LINCSwitch.onosDir, LINCSwitch.controllers[ index ].ip), shell=True) |
| 450 | - # successful output contains the two characters '{}' | 450 | + # successful output contains the two characters '{}' |
| 451 | - # if there is more output than this, there is an issue | 451 | + # if there is more output than this, there is an issue |
| 452 | - if output.strip('{}'): | 452 | + if output.strip('{}'): |
| 453 | - warn('***WARNING: Could not push topology file to ONOS: %s\n' % output) | 453 | + warn('***WARNING: Could not push topology file to ONOS: %s\n' % output) |
| 454 | 454 | ||
| 455 | @staticmethod | 455 | @staticmethod |
| 456 | def waitStarted(net, timeout=TIMEOUT): | 456 | def waitStarted(net, timeout=TIMEOUT): | ... | ... |
| ... | @@ -16,13 +16,16 @@ | ... | @@ -16,13 +16,16 @@ |
| 16 | package org.onosproject.rest.resources; | 16 | package org.onosproject.rest.resources; |
| 17 | 17 | ||
| 18 | import com.fasterxml.jackson.databind.JsonNode; | 18 | import com.fasterxml.jackson.databind.JsonNode; |
| 19 | +import com.google.common.base.Strings; | ||
| 19 | import com.google.common.collect.Lists; | 20 | import com.google.common.collect.Lists; |
| 21 | +import com.google.common.collect.Maps; | ||
| 20 | 22 | ||
| 21 | import org.onlab.packet.ChassisId; | 23 | import org.onlab.packet.ChassisId; |
| 22 | import org.onlab.packet.IpAddress; | 24 | import org.onlab.packet.IpAddress; |
| 23 | import org.onlab.packet.MacAddress; | 25 | import org.onlab.packet.MacAddress; |
| 24 | import org.onlab.packet.VlanId; | 26 | import org.onlab.packet.VlanId; |
| 25 | import org.onlab.util.Frequency; | 27 | import org.onlab.util.Frequency; |
| 28 | +import org.onosproject.net.AnnotationKeys; | ||
| 26 | import org.onosproject.net.ChannelSpacing; | 29 | import org.onosproject.net.ChannelSpacing; |
| 27 | import org.onosproject.net.ConnectPoint; | 30 | import org.onosproject.net.ConnectPoint; |
| 28 | import org.onosproject.net.DefaultAnnotations; | 31 | import org.onosproject.net.DefaultAnnotations; |
| ... | @@ -40,6 +43,7 @@ import org.onosproject.net.OduCltPort; | ... | @@ -40,6 +43,7 @@ import org.onosproject.net.OduCltPort; |
| 40 | import org.onosproject.net.OduSignalType; | 43 | import org.onosproject.net.OduSignalType; |
| 41 | import org.onosproject.net.OmsPort; | 44 | import org.onosproject.net.OmsPort; |
| 42 | import org.onosproject.net.Port; | 45 | import org.onosproject.net.Port; |
| 46 | +import org.onosproject.net.PortNumber; | ||
| 43 | import org.onosproject.net.SparseAnnotations; | 47 | import org.onosproject.net.SparseAnnotations; |
| 44 | import org.onosproject.net.device.DefaultDeviceDescription; | 48 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 45 | import org.onosproject.net.device.DefaultPortDescription; | 49 | import org.onosproject.net.device.DefaultPortDescription; |
| ... | @@ -71,6 +75,7 @@ import java.util.ArrayList; | ... | @@ -71,6 +75,7 @@ import java.util.ArrayList; |
| 71 | import java.util.HashSet; | 75 | import java.util.HashSet; |
| 72 | import java.util.Iterator; | 76 | import java.util.Iterator; |
| 73 | import java.util.List; | 77 | import java.util.List; |
| 78 | +import java.util.Map; | ||
| 74 | import java.util.Set; | 79 | import java.util.Set; |
| 75 | import java.util.concurrent.CountDownLatch; | 80 | import java.util.concurrent.CountDownLatch; |
| 76 | import java.util.concurrent.TimeUnit; | 81 | import java.util.concurrent.TimeUnit; |
| ... | @@ -113,6 +118,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -113,6 +118,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 113 | 118 | ||
| 114 | private DeviceListener deviceEventCounter = new DeviceEventCounter(); | 119 | private DeviceListener deviceEventCounter = new DeviceEventCounter(); |
| 115 | private List<ConnectPoint> connectPoints = Lists.newArrayList(); | 120 | private List<ConnectPoint> connectPoints = Lists.newArrayList(); |
| 121 | + private Map<ConnectPoint, PortDescription> descriptions = Maps.newHashMap(); | ||
| 116 | 122 | ||
| 117 | /** | 123 | /** |
| 118 | * Creates a new configuration provider. | 124 | * Creates a new configuration provider. |
| ... | @@ -216,24 +222,29 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -216,24 +222,29 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 216 | // Parses the given node with port information. | 222 | // Parses the given node with port information. |
| 217 | private PortDescription parsePort(JsonNode node) { | 223 | private PortDescription parsePort(JsonNode node) { |
| 218 | Port.Type type = Port.Type.valueOf(node.path("type").asText("COPPER")); | 224 | Port.Type type = Port.Type.valueOf(node.path("type").asText("COPPER")); |
| 225 | + PortNumber port = portNumber(node.path("port").asLong(0)); | ||
| 226 | + String portName = Strings.emptyToNull(port.name()); | ||
| 227 | + SparseAnnotations annotations = null; | ||
| 228 | + if (portName != null) { | ||
| 229 | + annotations = DefaultAnnotations.builder() | ||
| 230 | + .set(AnnotationKeys.PORT_NAME, portName).build(); | ||
| 231 | + } | ||
| 219 | switch (type) { | 232 | switch (type) { |
| 220 | case COPPER: | 233 | case COPPER: |
| 221 | - return new DefaultPortDescription(portNumber(node.path("port").asLong(0)), | 234 | + return new DefaultPortDescription(port, node.path("enabled").asBoolean(true), |
| 222 | - node.path("enabled").asBoolean(true), | 235 | + type, node.path("speed").asLong(1_000), |
| 223 | - type, node.path("speed").asLong(1_000)); | 236 | + annotations); |
| 224 | case FIBER: | 237 | case FIBER: |
| 225 | // Currently, assume OMS when FIBER. Provide sane defaults. | 238 | // Currently, assume OMS when FIBER. Provide sane defaults. |
| 226 | - return new OmsPortDescription(portNumber(node.path("port").asLong(0)), | 239 | + return new OmsPortDescription(port, node.path("enabled").asBoolean(true), |
| 227 | - node.path("enabled").asBoolean(true), | 240 | + CENTER, CENTER.add(TOTAL), |
| 228 | - CENTER, | 241 | + Frequency.ofGHz(100), annotations); |
| 229 | - CENTER.add(TOTAL), | ||
| 230 | - Frequency.ofGHz(100)); | ||
| 231 | default: | 242 | default: |
| 232 | log.warn("{}: Unsupported Port Type"); | 243 | log.warn("{}: Unsupported Port Type"); |
| 233 | } | 244 | } |
| 234 | - return new DefaultPortDescription(portNumber(node.path("port").asLong(0)), | 245 | + return new DefaultPortDescription(port, node.path("enabled").asBoolean(true), |
| 235 | - node.path("enabled").asBoolean(true), | 246 | + type, node.path("speed").asLong(1_000), |
| 236 | - type, node.path("speed").asLong(1_000)); | 247 | + annotations); |
| 237 | } | 248 | } |
| 238 | 249 | ||
| 239 | // Parses the given JSON and provides links as configured. | 250 | // Parses the given JSON and provides links as configured. |
| ... | @@ -267,17 +278,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -267,17 +278,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 267 | } | 278 | } |
| 268 | 279 | ||
| 269 | private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) { | 280 | private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) { |
| 270 | - DeviceId srcId = src.deviceId(); | ||
| 271 | - DeviceId dstId = dst.deviceId(); | ||
| 272 | - Port srcPort = deviceService.getPort(srcId, src.port()); | ||
| 273 | - Port dstPort = deviceService.getPort(dstId, dst.port()); | ||
| 274 | - | ||
| 275 | final String linkType = annotations.value("optical.type"); | 281 | final String linkType = annotations.value("optical.type"); |
| 276 | if ("cross-connect".equals(linkType)) { | 282 | if ("cross-connect".equals(linkType)) { |
| 277 | String value = annotations.value("bandwidth").trim(); | 283 | String value = annotations.value("bandwidth").trim(); |
| 278 | try { | 284 | try { |
| 279 | double bw = Double.parseDouble(value); | 285 | double bw = Double.parseDouble(value); |
| 280 | - updateOchPort(bw, srcPort, dstPort, srcId, dstId); | 286 | + updateOchPort(bw, src, dst); |
| 281 | } catch (NumberFormatException e) { | 287 | } catch (NumberFormatException e) { |
| 282 | log.warn("Invalid bandwidth ({}), can't configure port(s)", value); | 288 | log.warn("Invalid bandwidth ({}), can't configure port(s)", value); |
| 283 | return; | 289 | return; |
| ... | @@ -286,7 +292,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -286,7 +292,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 286 | String value = annotations.value("optical.waves").trim(); | 292 | String value = annotations.value("optical.waves").trim(); |
| 287 | try { | 293 | try { |
| 288 | int numChls = Integer.parseInt(value); | 294 | int numChls = Integer.parseInt(value); |
| 289 | - updateOMSPorts(numChls, srcPort, dstPort, srcId, dstId); | 295 | + updateOMSPorts(numChls, src, dst); |
| 290 | } catch (NumberFormatException e) { | 296 | } catch (NumberFormatException e) { |
| 291 | log.warn("Invalid channel ({}), can't configure port(s)", value); | 297 | log.warn("Invalid channel ({}), can't configure port(s)", value); |
| 292 | return; | 298 | return; |
| ... | @@ -295,10 +301,10 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -295,10 +301,10 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 295 | } | 301 | } |
| 296 | 302 | ||
| 297 | // uses 'bandwidth' annotation to determine the channel spacing. | 303 | // uses 'bandwidth' annotation to determine the channel spacing. |
| 298 | - private void updateOchPort(double bw, Port srcPort, Port dstPort, DeviceId srcId, DeviceId dstId) { | 304 | + private void updateOchPort(double bw, ConnectPoint srcCp, ConnectPoint dstCp) { |
| 299 | - Device src = deviceService.getDevice(srcId); | 305 | + Device src = deviceService.getDevice(srcCp.deviceId()); |
| 300 | - Device dst = deviceService.getDevice(dstId); | 306 | + Device dst = deviceService.getDevice(dstCp.deviceId()); |
| 301 | - // bandwidth in MHz (assuming Hz - linc is not clear if Hz or b). | 307 | + // bandwidth in MHz (assuming Hz - linc is not clear if that or Mb). |
| 302 | Frequency spacing = Frequency.ofMHz(bw); | 308 | Frequency spacing = Frequency.ofMHz(bw); |
| 303 | // channel bandwidth is smaller than smallest standard channel spacing. | 309 | // channel bandwidth is smaller than smallest standard channel spacing. |
| 304 | ChannelSpacing chsp = null; | 310 | ChannelSpacing chsp = null; |
| ... | @@ -319,20 +325,21 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -319,20 +325,21 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 319 | } | 325 | } |
| 320 | OchSignal signal = new OchSignal(GridType.DWDM, chsp, 1, 1); | 326 | OchSignal signal = new OchSignal(GridType.DWDM, chsp, 1, 1); |
| 321 | if (src.type() == Device.Type.ROADM) { | 327 | if (src.type() == Device.Type.ROADM) { |
| 322 | - PortDescription portDesc = new OchPortDescription(srcPort.number(), srcPort.isEnabled(), | 328 | + PortDescription portDesc = new OchPortDescription(srcCp.port(), true, |
| 323 | OduSignalType.ODU4, true, signal); | 329 | OduSignalType.ODU4, true, signal); |
| 324 | - deviceProviderService.portStatusChanged(srcId, portDesc); | 330 | + descriptions.put(srcCp, portDesc); |
| 331 | + deviceProviderService.portStatusChanged(srcCp.deviceId(), portDesc); | ||
| 325 | } | 332 | } |
| 326 | if (dst.type() == Device.Type.ROADM) { | 333 | if (dst.type() == Device.Type.ROADM) { |
| 327 | - PortDescription portDesc = new OchPortDescription(dstPort.number(), dstPort.isEnabled(), | 334 | + PortDescription portDesc = new OchPortDescription(dstCp.port(), true, |
| 328 | OduSignalType.ODU4, true, signal); | 335 | OduSignalType.ODU4, true, signal); |
| 329 | - deviceProviderService.portStatusChanged(dstId, portDesc); | 336 | + descriptions.put(dstCp, portDesc); |
| 337 | + deviceProviderService.portStatusChanged(dstCp.deviceId(), portDesc); | ||
| 330 | } | 338 | } |
| 331 | } | 339 | } |
| 332 | 340 | ||
| 333 | - private void updateOMSPorts(int numChls, Port srcPort, Port dstPort, DeviceId srcId, DeviceId dstId) { | 341 | + private void updateOMSPorts(int numChls, ConnectPoint srcCp, ConnectPoint dstCp) { |
| 334 | - // round down to largest slot that allows numChl channels to fit into C | 342 | + // round down to largest slot that allows numChl channels to fit into C band range |
| 335 | - // band range | ||
| 336 | ChannelSpacing chl = null; | 343 | ChannelSpacing chl = null; |
| 337 | Frequency perChl = TOTAL.floorDivision(numChls); | 344 | Frequency perChl = TOTAL.floorDivision(numChls); |
| 338 | for (int i = 0; i < ChannelSpacing.values().length; i++) { | 345 | for (int i = 0; i < ChannelSpacing.values().length; i++) { |
| ... | @@ -352,10 +359,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -352,10 +359,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 352 | Frequency min = CENTER.add(grid); | 359 | Frequency min = CENTER.add(grid); |
| 353 | Frequency max = CENTER.add(grid.multiply(numChls)); | 360 | Frequency max = CENTER.add(grid.multiply(numChls)); |
| 354 | 361 | ||
| 355 | - PortDescription srcPortDesc = new OmsPortDescription(srcPort.number(), srcPort.isEnabled(), min, max, grid); | 362 | + PortDescription srcPortDesc = new OmsPortDescription(srcCp.port(), true, min, max, grid); |
| 356 | - PortDescription dstPortDesc = new OmsPortDescription(dstPort.number(), dstPort.isEnabled(), min, max, grid); | 363 | + PortDescription dstPortDesc = new OmsPortDescription(dstCp.port(), true, min, max, grid); |
| 357 | - deviceProviderService.portStatusChanged(srcId, srcPortDesc); | 364 | + descriptions.put(srcCp, srcPortDesc); |
| 358 | - deviceProviderService.portStatusChanged(dstId, dstPortDesc); | 365 | + descriptions.put(dstCp, dstPortDesc); |
| 366 | + deviceProviderService.portStatusChanged(srcCp.deviceId(), srcPortDesc); | ||
| 367 | + deviceProviderService.portStatusChanged(dstCp.deviceId(), dstPortDesc); | ||
| 359 | } | 368 | } |
| 360 | 369 | ||
| 361 | // Parses the given JSON and provides hosts as configured. | 370 | // Parses the given JSON and provides hosts as configured. |
| ... | @@ -440,8 +449,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -440,8 +449,12 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
| 440 | } | 449 | } |
| 441 | } | 450 | } |
| 442 | 451 | ||
| 443 | - // Creates a port description from the specified connection point. | 452 | + // Creates a port description from the specified connection point if none created earlier. |
| 444 | private PortDescription description(ConnectPoint cp) { | 453 | private PortDescription description(ConnectPoint cp) { |
| 454 | + PortDescription saved = descriptions.get(cp); | ||
| 455 | + if (saved != null) { | ||
| 456 | + return saved; | ||
| 457 | + } | ||
| 445 | Port p = deviceService.getPort(cp.deviceId(), cp.port()); | 458 | Port p = deviceService.getPort(cp.deviceId(), cp.port()); |
| 446 | if (p == null) { | 459 | if (p == null) { |
| 447 | return new DefaultPortDescription(cp.port(), true); | 460 | return new DefaultPortDescription(cp.port(), true); | ... | ... |
-
Please register or login to post a comment