Committed by
Gerrit Code Review
Fix for parsing non-numeric port numbers in ConfigProvider
Change-Id: I891bd4f13ecb76f6679db3262f3050ec983b4372
Showing
2 changed files
with
14 additions
and
5 deletions
... | @@ -96,6 +96,17 @@ public final class PortNumber { | ... | @@ -96,6 +96,17 @@ public final class PortNumber { |
96 | } | 96 | } |
97 | 97 | ||
98 | /** | 98 | /** |
99 | + * Returns the port number representing the specified long value and name. | ||
100 | + * | ||
101 | + * @param number port number as string value | ||
102 | + * @param name port name as string value | ||
103 | + * @return port number | ||
104 | + */ | ||
105 | + public static PortNumber portNumber(String number, String name) { | ||
106 | + return new PortNumber(UnsignedLongs.decode(number), name); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
99 | * Indicates whether or not this port number is a reserved logical one or | 110 | * Indicates whether or not this port number is a reserved logical one or |
100 | * whether it corresponds to a normal physical port of a device or NIC. | 111 | * whether it corresponds to a normal physical port of a device or NIC. |
101 | * | 112 | * | ... | ... |
... | @@ -278,9 +278,6 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -278,9 +278,6 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
278 | } | 278 | } |
279 | 279 | ||
280 | private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) { | 280 | private void updatePorts(ConnectPoint src, ConnectPoint dst, SparseAnnotations annotations) { |
281 | - if (annotations == null) { | ||
282 | - return; | ||
283 | - } | ||
284 | final String linkType = annotations.value("optical.type"); | 281 | final String linkType = annotations.value("optical.type"); |
285 | if ("cross-connect".equals(linkType)) { | 282 | if ("cross-connect".equals(linkType)) { |
286 | String value = annotations.value("bandwidth").trim(); | 283 | String value = annotations.value("bandwidth").trim(); |
... | @@ -468,7 +465,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -468,7 +465,7 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
468 | // Produces set of annotations from the given JSON node. | 465 | // Produces set of annotations from the given JSON node. |
469 | private SparseAnnotations annotations(JsonNode node) { | 466 | private SparseAnnotations annotations(JsonNode node) { |
470 | if (node == null) { | 467 | if (node == null) { |
471 | - return null; | 468 | + return (SparseAnnotations) DefaultAnnotations.EMPTY; |
472 | } | 469 | } |
473 | 470 | ||
474 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); | 471 | DefaultAnnotations.Builder builder = DefaultAnnotations.builder(); |
... | @@ -483,8 +480,9 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { | ... | @@ -483,8 +480,9 @@ class ConfigProvider implements DeviceProvider, LinkProvider, HostProvider { |
483 | // Produces a connection point from the specified uri/port text. | 480 | // Produces a connection point from the specified uri/port text. |
484 | private ConnectPoint connectPoint(String text) { | 481 | private ConnectPoint connectPoint(String text) { |
485 | int i = text.lastIndexOf("/"); | 482 | int i = text.lastIndexOf("/"); |
483 | + String portStr = text.substring(i + 1); | ||
486 | return new ConnectPoint(deviceId(text.substring(0, i)), | 484 | return new ConnectPoint(deviceId(text.substring(0, i)), |
487 | - portNumber(text.substring(i + 1))); | 485 | + portNumber(portStr.matches(".*[a-zA-Z].*") ? "0" : portStr, portStr)); |
488 | } | 486 | } |
489 | 487 | ||
490 | // Returns string form of the named property in the given JSON object. | 488 | // Returns string form of the named property in the given JSON object. | ... | ... |
-
Please register or login to post a comment