- List<Adjacency> adjList = new ArrayList<Adjacency>();
- for (String route : routeList) {
- // assuming extra route is strictly in the format "nexthop destination" > "10.1.1.10 40.0.1.0/24"
- String[] parts = route.split(" ");
- if (parts.length == 2) {
- String nextHop = parts[0];
- String destination = parts[1];
-
- String tapPortName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
- String ifname = new StringBuilder(tapPortName).append(":0").toString();
- logger.trace("Adding extra route with nexthop {}, destination {}, ifName {}", nextHop,
- destination, ifname);
- Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIp(nextHop).setKey
- (new AdjacencyKey(destination)).build();
- if (rtrUp == false) {
- if (ifname.equals(vpnifname)) {
- adjList.add(erAdj);
- }
- continue;
+ isLockAcquired = NeutronvpnUtils.lock(lockManager, lockName);
+ checkAndPublishSubnetUpdNotification(subnet, sn.getSubnetIp(), vpnId.getValue(), isBeingAssociated, elanTag);
+ logger.debug("Subnet updated in Vpn notification sent");
+ }catch (Exception e){
+ logger.error("Subnet updated in Vpn notification failed",e);
+ }finally {
+ if (isLockAcquired) {
+ NeutronvpnUtils.unlock(lockManager, lockName);
+ }
+ }
+ // Check for ports on this subnet and update association of corresponding vpn-interfaces to external vpn
+ List<Uuid> portList = sn.getPortList();
+ if (portList != null) {
+ for (Uuid port : sn.getPortList()) {
+ logger.debug("Updating vpn-interface for port {}", port.getValue());
+ updateVpnInterface(vpnId, NeutronvpnUtils.getNeutronPort(broker, port));
+ }
+ }
+ }
+
+
+
+ // router-interfaces-map
+// list router-interfaces {
+// key router-id;
+// leaf router-id { type yang:uuid; }
+// list interfaces {
+// key interface-id;
+// leaf interface-id { type yang:uuid; }
+// }
+// }
+////}
+ InstanceIdentifier<RouterInterfaces> getRouterInterfacesId(Uuid routerId) {
+ return InstanceIdentifier.builder(RouterInterfacesMap.class)
+ .child(RouterInterfaces.class, new RouterInterfacesKey(routerId)).build();
+ }
+ void addToNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
+ InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
+ Optional<RouterInterfaces> optRouterInterfaces = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
+ Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
+ if(optRouterInterfaces.isPresent()) {
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)), routerInterface);
+ } else {
+ RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
+ List<Interfaces> interfaces = new ArrayList<>();
+ interfaces.add(routerInterface);
+ MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId, builder.setInterfaces(interfaces).build());
+ }
+ }
+
+ void removeFromNeutronRouterInterfacesMap(Uuid routerId, String interfaceName) {
+ InstanceIdentifier<RouterInterfaces> routerInterfacesId = getRouterInterfacesId(routerId);
+ Optional<RouterInterfaces> optRouterInterfaces = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
+ Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName)).setInterfaceId(interfaceName).build();
+ if(optRouterInterfaces.isPresent()) {
+ RouterInterfaces routerInterfaces = optRouterInterfaces.get();
+ List<Interfaces> interfaces = routerInterfaces.getInterfaces();
+ if(interfaces != null && interfaces.remove(routerInterface)) {
+ if(interfaces.isEmpty()) {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
+ } else {
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)));
+ }
+ }
+ }
+ }
+
+ protected List<Adjacency> addAdjacencyforExtraRoute(List<Routes> routeList, boolean rtrUp, String vpnifname) {
+ List<Adjacency> adjList = new ArrayList<Adjacency>();
+ for (Routes route : routeList) {
+ if (route != null && route.getNexthop() != null && route.getDestination() != null) {
+ boolean isLockAcquired = false;
+ String nextHop = String.valueOf(route.getNexthop().getValue());
+ String destination = String.valueOf(route.getDestination().getValue());
+
+ String infName = NeutronvpnUtils.getNeutronPortNamefromPortFixedIp(broker, nextHop);
+ logger.trace("Adding extra route with nexthop {}, destination {}, infName {}", nextHop,
+ destination, infName);
+ Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIp(nextHop).setKey
+ (new AdjacencyKey(destination)).build();
+ if (rtrUp == false) {
+ if (infName.equals(vpnifname)) {
+ adjList.add(erAdj);