ConfigProvider: Use port number from known ports to create ConnectPoints
Change-Id: Iecab56927815e6e5db97a3caf7c742f5a68ccc01
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
index 296337f..c7feaea 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/ConfigProvider.java
@@ -509,9 +509,17 @@
// Produces a connection point from the specified uri/port text.
private ConnectPoint connectPoint(String text) {
int i = text.lastIndexOf("/");
- String portStr = text.substring(i + 1);
- return new ConnectPoint(deviceId(text.substring(0, i)),
- portNumber(portStr.matches(".*[a-zA-Z].*") ? "0" : portStr, portStr));
+ String portName = text.substring(i + 1);
+ DeviceId deviceId = deviceId(text.substring(0, i));
+
+ long portNum = 0L;
+ for (Port port : deviceService.getPorts(deviceId)) {
+ PortNumber pn = port.number();
+ if (pn.name().equals(portName)) {
+ return new ConnectPoint(deviceId, pn);
+ }
+ }
+ return new ConnectPoint(deviceId, portNumber(portNum, portName));
}
// Returns string form of the named property in the given JSON object.