Committed by
Gerrit Code Review
ONOS-3237 Change OvsdbNodeId value ovsdb:ip:port to ovsdb:ip.
Change-Id: I6c13d740c2d0f4ce4efe73fe0ce5fa3d50a65c0c
Showing
3 changed files
with
15 additions
and
18 deletions
... | @@ -114,16 +114,15 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour | ... | @@ -114,16 +114,15 @@ public class OvsdbBridgeConfig extends AbstractHandlerBehaviour |
114 | .collect(Collectors.toSet()); | 114 | .collect(Collectors.toSet()); |
115 | } | 115 | } |
116 | 116 | ||
117 | - // OvsdbNodeId(IP:port) is used in the adaptor while DeviceId(ovsdb:IP:port) | 117 | + // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) |
118 | // is used in the core. So DeviceId need be changed to OvsdbNodeId. | 118 | // is used in the core. So DeviceId need be changed to OvsdbNodeId. |
119 | private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { | 119 | private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { |
120 | - int lastColon = deviceId.toString().lastIndexOf(":"); | 120 | + String[] splits = deviceId.toString().split(":"); |
121 | - int fistColon = deviceId.toString().indexOf(":"); | 121 | + if (splits == null || splits.length < 1) { |
122 | - String ip = deviceId.toString().substring(fistColon + 1, lastColon); | 122 | + return null; |
123 | - String port = deviceId.toString().substring(lastColon + 1); | 123 | + } |
124 | - IpAddress ipAddress = IpAddress.valueOf(ip); | 124 | + IpAddress ipAddress = IpAddress.valueOf(splits[0]); |
125 | - long portL = Long.parseLong(port); | 125 | + return new OvsdbNodeId(ipAddress, 0); |
126 | - return new OvsdbNodeId(ipAddress, portL); | ||
127 | } | 126 | } |
128 | 127 | ||
129 | // Used for getting OvsdbClientService. | 128 | // Used for getting OvsdbClientService. | ... | ... |
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.driver.ovsdb; | 16 | package org.onosproject.driver.ovsdb; |
17 | 17 | ||
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | - | ||
20 | import java.util.Set; | 19 | import java.util.Set; |
21 | import java.util.stream.Collectors; | 20 | import java.util.stream.Collectors; |
22 | 21 | ||
... | @@ -102,16 +101,15 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour | ... | @@ -102,16 +101,15 @@ public class OvsdbTunnelConfig extends AbstractHandlerBehaviour |
102 | .collect(Collectors.toSet()); | 101 | .collect(Collectors.toSet()); |
103 | } | 102 | } |
104 | 103 | ||
105 | - // OvsdbNodeId(IP:port) is used in the adaptor while DeviceId(ovsdb:IP:port) | 104 | + // OvsdbNodeId(IP) is used in the adaptor while DeviceId(ovsdb:IP) |
106 | // is used in the core. So DeviceId need be changed to OvsdbNodeId. | 105 | // is used in the core. So DeviceId need be changed to OvsdbNodeId. |
107 | private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { | 106 | private OvsdbNodeId changeDeviceIdToNodeId(DeviceId deviceId) { |
108 | - int lastColon = deviceId.toString().lastIndexOf(":"); | 107 | + String[] splits = deviceId.toString().split(":"); |
109 | - int fistColon = deviceId.toString().indexOf(":"); | 108 | + if (splits == null || splits.length < 1) { |
110 | - String ip = deviceId.toString().substring(fistColon + 1, lastColon); | 109 | + return null; |
111 | - String port = deviceId.toString().substring(lastColon + 1); | 110 | + } |
112 | - IpAddress ipAddress = IpAddress.valueOf(ip); | 111 | + IpAddress ipAddress = IpAddress.valueOf(splits[0]); |
113 | - long portL = Long.parseLong(port); | 112 | + return new OvsdbNodeId(ipAddress, 0); |
114 | - return new OvsdbNodeId(ipAddress, portL); | ||
115 | } | 113 | } |
116 | 114 | ||
117 | private OvsdbClientService getOvsdbNode(DriverHandler handler) { | 115 | private OvsdbClientService getOvsdbNode(DriverHandler handler) { | ... | ... |
... | @@ -39,7 +39,7 @@ public final class OvsdbNodeId { | ... | @@ -39,7 +39,7 @@ public final class OvsdbNodeId { |
39 | public OvsdbNodeId(IpAddress ipAddress, long port) { | 39 | public OvsdbNodeId(IpAddress ipAddress, long port) { |
40 | checkNotNull(ipAddress, "ipAddress is not null"); | 40 | checkNotNull(ipAddress, "ipAddress is not null"); |
41 | this.ipAddress = ipAddress.toString(); | 41 | this.ipAddress = ipAddress.toString(); |
42 | - this.nodeId = ipAddress + ":" + port; | 42 | + this.nodeId = ipAddress.toString(); |
43 | } | 43 | } |
44 | 44 | ||
45 | @Override | 45 | @Override | ... | ... |
-
Please register or login to post a comment