[ONOS-3640] Update VTN's bug which is caused by onos restart when doing
APEX installer: it should not create the external port which name is default external port name. Change-Id: If69b60bdd6d16f203a94db14e7d29d7a8f270fc2
Showing
1 changed file
with
24 additions
and
7 deletions
... | @@ -19,6 +19,7 @@ import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.Exten | ... | @@ -19,6 +19,7 @@ import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.Exten |
19 | import static org.slf4j.LoggerFactory.getLogger; | 19 | import static org.slf4j.LoggerFactory.getLogger; |
20 | 20 | ||
21 | import java.util.ArrayList; | 21 | import java.util.ArrayList; |
22 | +import java.util.Arrays; | ||
22 | import java.util.Collection; | 23 | import java.util.Collection; |
23 | import java.util.HashMap; | 24 | import java.util.HashMap; |
24 | import java.util.HashSet; | 25 | import java.util.HashSet; |
... | @@ -75,9 +76,12 @@ import org.onosproject.net.host.HostEvent; | ... | @@ -75,9 +76,12 @@ import org.onosproject.net.host.HostEvent; |
75 | import org.onosproject.net.host.HostListener; | 76 | import org.onosproject.net.host.HostListener; |
76 | import org.onosproject.net.host.HostService; | 77 | import org.onosproject.net.host.HostService; |
77 | import org.onosproject.store.serializers.KryoNamespaces; | 78 | import org.onosproject.store.serializers.KryoNamespaces; |
79 | +import org.onosproject.store.service.ConsistentMap; | ||
78 | import org.onosproject.store.service.EventuallyConsistentMap; | 80 | import org.onosproject.store.service.EventuallyConsistentMap; |
79 | import org.onosproject.store.service.LogicalClockService; | 81 | import org.onosproject.store.service.LogicalClockService; |
82 | +import org.onosproject.store.service.Serializer; | ||
80 | import org.onosproject.store.service.StorageService; | 83 | import org.onosproject.store.service.StorageService; |
84 | +import org.onosproject.store.service.Versioned; | ||
81 | import org.onosproject.vtn.manager.VTNService; | 85 | import org.onosproject.vtn.manager.VTNService; |
82 | import org.onosproject.vtn.table.ArpService; | 86 | import org.onosproject.vtn.table.ArpService; |
83 | import org.onosproject.vtn.table.ClassifierService; | 87 | import org.onosproject.vtn.table.ClassifierService; |
... | @@ -188,7 +192,7 @@ public class VTNManager implements VTNService { | ... | @@ -188,7 +192,7 @@ public class VTNManager implements VTNService { |
188 | private final DeviceListener deviceListener = new InnerDeviceListener(); | 192 | private final DeviceListener deviceListener = new InnerDeviceListener(); |
189 | private final VtnRscListener l3EventListener = new VtnL3EventListener(); | 193 | private final VtnRscListener l3EventListener = new VtnL3EventListener(); |
190 | 194 | ||
191 | - private static String exPortName = "eth0"; | 195 | + private static final String EX_PORT_KEY = "exPortKey"; |
192 | private static final String IFACEID = "ifaceid"; | 196 | private static final String IFACEID = "ifaceid"; |
193 | private static final String CONTROLLER_IP_KEY = "ipaddress"; | 197 | private static final String CONTROLLER_IP_KEY = "ipaddress"; |
194 | public static final String DRIVER_NAME = "onosfw"; | 198 | public static final String DRIVER_NAME = "onosfw"; |
... | @@ -198,6 +202,7 @@ public class VTNManager implements VTNService { | ... | @@ -198,6 +202,7 @@ public class VTNManager implements VTNService { |
198 | private static final String ROUTERINF_FLAG_OF_TENANT = "routerInfFlagOfTenant"; | 202 | private static final String ROUTERINF_FLAG_OF_TENANT = "routerInfFlagOfTenant"; |
199 | private static final String HOSTS_OF_SUBNET = "hostsOfSubnet"; | 203 | private static final String HOSTS_OF_SUBNET = "hostsOfSubnet"; |
200 | private static final String EX_PORT_OF_DEVICE = "exPortOfDevice"; | 204 | private static final String EX_PORT_OF_DEVICE = "exPortOfDevice"; |
205 | + private static final String EX_PORT_MAP = "exPortMap"; | ||
201 | private static final String DEFAULT_IP = "0.0.0.0"; | 206 | private static final String DEFAULT_IP = "0.0.0.0"; |
202 | private static final int SUBNET_NUM = 2; | 207 | private static final int SUBNET_NUM = 2; |
203 | 208 | ||
... | @@ -207,6 +212,7 @@ public class VTNManager implements VTNService { | ... | @@ -207,6 +212,7 @@ public class VTNManager implements VTNService { |
207 | private EventuallyConsistentMap<SubnetId, Map<HostId, Host>> hostsOfSubnet; | 212 | private EventuallyConsistentMap<SubnetId, Map<HostId, Host>> hostsOfSubnet; |
208 | private EventuallyConsistentMap<TenantId, Boolean> routerInfFlagOfTenant; | 213 | private EventuallyConsistentMap<TenantId, Boolean> routerInfFlagOfTenant; |
209 | private EventuallyConsistentMap<DeviceId, Port> exPortOfDevice; | 214 | private EventuallyConsistentMap<DeviceId, Port> exPortOfDevice; |
215 | + private static ConsistentMap<String, String> exPortMap; | ||
210 | 216 | ||
211 | @Activate | 217 | @Activate |
212 | public void activate() { | 218 | public void activate() { |
... | @@ -275,6 +281,14 @@ public class VTNManager implements VTNService { | ... | @@ -275,6 +281,14 @@ public class VTNManager implements VTNService { |
275 | .withTimestampProvider((k, v) -> clockService.getTimestamp()) | 281 | .withTimestampProvider((k, v) -> clockService.getTimestamp()) |
276 | .build(); | 282 | .build(); |
277 | 283 | ||
284 | + exPortMap = storageService | ||
285 | + .<String, String>consistentMapBuilder() | ||
286 | + .withName(EX_PORT_MAP) | ||
287 | + .withApplicationId(appId) | ||
288 | + .withPurgeOnUninstall() | ||
289 | + .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API))) | ||
290 | + .build(); | ||
291 | + | ||
278 | log.info("Started"); | 292 | log.info("Started"); |
279 | } | 293 | } |
280 | 294 | ||
... | @@ -310,8 +324,11 @@ public class VTNManager implements VTNService { | ... | @@ -310,8 +324,11 @@ public class VTNManager implements VTNService { |
310 | config.driver(DRIVER_NAME); | 324 | config.driver(DRIVER_NAME); |
311 | configService.applyConfig(deviceId, BasicDeviceConfig.class, config.node()); | 325 | configService.applyConfig(deviceId, BasicDeviceConfig.class, config.node()); |
312 | // Add Bridge | 326 | // Add Bridge |
313 | - VtnConfig.applyBridgeConfig(handler, dpid, exPortName); | 327 | + Versioned<String> exPortVersioned = exPortMap.get(EX_PORT_KEY); |
314 | - log.info("A new ovs is created in node {}", localIp.toString()); | 328 | + if (exPortVersioned != null) { |
329 | + VtnConfig.applyBridgeConfig(handler, dpid, exPortVersioned.value()); | ||
330 | + log.info("A new ovs is created in node {}", localIp.toString()); | ||
331 | + } | ||
315 | switchesOfController.put(localIp, true); | 332 | switchesOfController.put(localIp, true); |
316 | } | 333 | } |
317 | // Create tunnel in br-int on all controllers | 334 | // Create tunnel in br-int on all controllers |
... | @@ -330,8 +347,6 @@ public class VTNManager implements VTNService { | ... | @@ -330,8 +347,6 @@ public class VTNManager implements VTNService { |
330 | if (mastershipService.isLocalMaster(controllerDeviceId)) { | 347 | if (mastershipService.isLocalMaster(controllerDeviceId)) { |
331 | switchesOfController.remove(dstIpAddress); | 348 | switchesOfController.remove(dstIpAddress); |
332 | } | 349 | } |
333 | - // remove tunnel in br-int on other controllers | ||
334 | - programTunnelConfig(controllerDeviceId, dstIpAddress, null); | ||
335 | } | 350 | } |
336 | 351 | ||
337 | @Override | 352 | @Override |
... | @@ -971,7 +986,9 @@ public class VTNManager implements VTNService { | ... | @@ -971,7 +986,9 @@ public class VTNManager implements VTNService { |
971 | Port exPort = null; | 986 | Port exPort = null; |
972 | for (Port port : ports) { | 987 | for (Port port : ports) { |
973 | String portName = port.annotations().value(AnnotationKeys.PORT_NAME); | 988 | String portName = port.annotations().value(AnnotationKeys.PORT_NAME); |
974 | - if (portName != null && portName.equals(exPortName)) { | 989 | + Versioned<String> exPortVersioned = exPortMap.get(EX_PORT_KEY); |
990 | + if (portName != null && exPortVersioned != null && portName. | ||
991 | + equals(exPortVersioned.value())) { | ||
975 | exPort = port; | 992 | exPort = port; |
976 | break; | 993 | break; |
977 | } | 994 | } |
... | @@ -1071,6 +1088,6 @@ public class VTNManager implements VTNService { | ... | @@ -1071,6 +1088,6 @@ public class VTNManager implements VTNService { |
1071 | } | 1088 | } |
1072 | 1089 | ||
1073 | public static void setExPortName(String name) { | 1090 | public static void setExPortName(String name) { |
1074 | - exPortName = name; | 1091 | + exPortMap.put(EX_PORT_KEY, name); |
1075 | } | 1092 | } |
1076 | } | 1093 | } | ... | ... |
-
Please register or login to post a comment