Committed by
Gerrit Code Review
ConfigProvider: Use port number from known ports to create ConnectPoints
Change-Id: Iecab56927815e6e5db97a3caf7c742f5a68ccc01
Showing
1 changed file
with
11 additions
and
3 deletions
... | @@ -509,9 +509,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -509,9 +509,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
509 | // Produces a connection point from the specified uri/port text. | 509 | // Produces a connection point from the specified uri/port text. |
510 | private ConnectPoint connectPoint(String text) { | 510 | private ConnectPoint connectPoint(String text) { |
511 | int i = text.lastIndexOf("/"); | 511 | int i = text.lastIndexOf("/"); |
512 | - String portStr = text.substring(i + 1); | 512 | + String portName = text.substring(i + 1); |
513 | - return new ConnectPoint(deviceId(text.substring(0, i)), | 513 | + DeviceId deviceId = deviceId(text.substring(0, i)); |
514 | - portNumber(portStr.matches(".*[a-zA-Z].*") ? "0" : portStr, portStr)); | 514 | + |
515 | + long portNum = 0L; | ||
516 | + for (Port port : deviceService.getPorts(deviceId)) { | ||
517 | + PortNumber pn = port.number(); | ||
518 | + if (pn.name().equals(portName)) { | ||
519 | + return new ConnectPoint(deviceId, pn); | ||
520 | + } | ||
521 | + } | ||
522 | + return new ConnectPoint(deviceId, portNumber(portNum, portName)); | ||
515 | } | 523 | } |
516 | 524 | ||
517 | // Returns string form of the named property in the given JSON object. | 525 | // Returns string form of the named property in the given JSON object. | ... | ... |
-
Please register or login to post a comment