- @Override
- protected void add(InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> identifier,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface add) {
- LOG.trace("Operational Interface add event - {}", add);
- String interfaceName = add.getName();
- Interface intf = getInterface(interfaceName);
- if (intf != null && intf.getType().equals(L3tunnel.class)) {
- BigInteger dpnId = interfaceManager.getDpnForInterface(interfaceName);
- if(add.getOperStatus().equals(OperStatus.Up)) {
- //Create ingress to LFIB
- LOG.debug("Installing Ingress for tunnel interface {}", interfaceName);
- makeTunnelIngressFlow(dpnId, interfaceName, NwConstants.ADD_FLOW);
+ InstanceIdentifier<DpnVpninterfacesList> getRouterDpnId(String routerName, BigInteger dpnId) {
+ return InstanceIdentifier.builder(NeutronRouterDpns.class)
+ .child(RouterDpnList.class, new RouterDpnListKey(routerName))
+ .child(DpnVpninterfacesList.class, new DpnVpninterfacesListKey(dpnId)).build();
+ }
+
+ InstanceIdentifier<RouterDpnList> getRouterId(String routerName) {
+ return InstanceIdentifier.builder(NeutronRouterDpns.class)
+ .child(RouterDpnList.class, new RouterDpnListKey(routerName)).build();
+ }
+
+ protected void addToNeutronRouterDpnsMap(String routerName, String vpnInterfaceName) {
+ BigInteger dpId = InterfaceUtils.getDpnForInterface(interfaceManager, vpnInterfaceName);
+ if(dpId.equals(BigInteger.ZERO)) {
+ LOG.warn("Could not retrieve dp id for interface {} to handle router {} association model", vpnInterfaceName, routerName);
+ return;
+ }
+ InstanceIdentifier<DpnVpninterfacesList> routerDpnListIdentifier = getRouterDpnId(routerName, dpId);
+
+ Optional<DpnVpninterfacesList> optionalRouterDpnList = VpnUtil.read(broker, LogicalDatastoreType
+ .CONFIGURATION, routerDpnListIdentifier);
+ RouterInterfaces routerInterface = new RouterInterfacesBuilder().setKey(new RouterInterfacesKey(vpnInterfaceName)).setInterface(vpnInterfaceName).build();
+ if (optionalRouterDpnList.isPresent()) {
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routerDpnListIdentifier.child(
+ RouterInterfaces.class, new RouterInterfacesKey(vpnInterfaceName)), routerInterface);
+ } else {
+ MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION,
+ getRouterId(routerName),
+ new RouterDpnListBuilder().setRouterId(routerName).build());
+ //VpnToDpnListBuilder vpnToDpnList = new VpnToDpnListBuilder().setDpnId(dpnId);
+ DpnVpninterfacesListBuilder dpnVpnList = new DpnVpninterfacesListBuilder().setDpnId(dpId);
+ List<RouterInterfaces> routerInterfaces = new ArrayList<>();
+ routerInterfaces.add(routerInterface);
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routerDpnListIdentifier,
+ dpnVpnList.setRouterInterfaces(routerInterfaces).build());
+ }
+ }
+
+ protected void removeFromNeutronRouterDpnsMap(String routerName, String vpnInterfaceName) {
+ BigInteger dpId = InterfaceUtils.getDpnForInterface(interfaceManager, vpnInterfaceName);
+ if(dpId.equals(BigInteger.ZERO)) {
+ LOG.warn("Could not retrieve dp id for interface {} to handle router {} dissociation model", vpnInterfaceName, routerName);
+ return;
+ }
+ InstanceIdentifier<DpnVpninterfacesList> routerDpnListIdentifier = getRouterDpnId(routerName, dpId);
+ Optional<DpnVpninterfacesList> optionalRouterDpnList = VpnUtil.read(broker, LogicalDatastoreType
+ .CONFIGURATION, routerDpnListIdentifier);
+ if (optionalRouterDpnList.isPresent()) {
+ List<RouterInterfaces> routerInterfaces = optionalRouterDpnList.get().getRouterInterfaces();
+ RouterInterfaces routerInterface = new RouterInterfacesBuilder().setKey(new RouterInterfacesKey(vpnInterfaceName)).setInterface(vpnInterfaceName).build();
+
+ if (routerInterfaces != null && routerInterfaces.remove(routerInterface)) {
+ if (routerInterfaces.isEmpty()) {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerDpnListIdentifier);
+ } else {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerDpnListIdentifier.child(
+ RouterInterfaces.class,
+ new RouterInterfacesKey(vpnInterfaceName)));