+
+ setExternalGwMac(routerGwPort, routerId);
+ }
+
+ private void setExternalGwMac(Port routerGwPort, Uuid routerId) {
+ // During full-sync networking-odl syncs routers before ports. As such,
+ // the MAC of the router's gw port is not available to be set when the
+ // router is written. We catch that here.
+ InstanceIdentifier<Routers> routersId = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
+ Optional<Routers> optionalRouter = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId);
+ if (!optionalRouter.isPresent()) {
+ return;
+ }
+
+ Routers extRouters = optionalRouter.get();
+ if (extRouters.getExtGwMacAddress() != null) {
+ return;
+ }
+
+ RoutersBuilder builder = new RoutersBuilder(extRouters);
+ builder.setExtGwMacAddress(routerGwPort.getMacAddress().getValue());
+ MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersId, builder.build());