Ayaka Koshibe
Committed by Gerrit Code Review

ConfigProvider: Use port number from known ports to create ConnectPoints

Change-Id: Iecab56927815e6e5db97a3caf7c742f5a68ccc01
......@@ -509,9 +509,17 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
// 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.
......