Ayaka Koshibe
Committed by Gerrit Code Review

Fix for parsing non-numeric port numbers in ConfigProvider

Change-Id: I891bd4f13ecb76f6679db3262f3050ec983b4372
......@@ -96,6 +96,17 @@ public final class PortNumber {
}
/**
* Returns the port number representing the specified long value and name.
*
* @param number port number as string value
* @param name port name as string value
* @return port number
*/
public static PortNumber portNumber(String number, String name) {
return new PortNumber(UnsignedLongs.decode(number), name);
}
/**
* Indicates whether or not this port number is a reserved logical one or
* whether it corresponds to a normal physical port of a device or NIC.
*
......
......@@ -278,9 +278,6 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
}
private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) {
if (annotations == null) {
return;
}
final String linkType = annotations.value("optical.type");
if ("cross-connect".equals(linkType)) {
String value = annotations.value("bandwidth").trim();
......@@ -468,7 +465,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider {
// Produces set of annotations from the given JSON node.
private SparseAnnotations annotations(JsonNode node) {
if (node == null) {
return null;
return (SparseAnnotations) DefaultAnnotations.EMPTY;
}
DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
......@@ -483,8 +480,9 @@ 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(text.substring(i + 1)));
portNumber(portStr.matches(".*[a-zA-Z].*") ? "0" : portStr, portStr));
}
// Returns string form of the named property in the given JSON object.
......