Fix for VPN Interface creation 35/20135/1
authorVishal Thapar <vishal.thapar@ericsson.com>
Tue, 12 May 2015 13:33:10 +0000 (19:03 +0530)
committerVishal Thapar <vishal.thapar@ericsson.com>
Tue, 12 May 2015 13:38:47 +0000 (19:08 +0530)
1. Fixed a wrong condition in NextHopManager.
2. Handle vlan-id not specified for l2vlan in interfacemanager
3. Return 0 instead of null if ofport is not found.

Change-Id: I6107ccc1d20c44a58ab12663e0f59ee1a4e4f04f
Signed-off-by: Vishal Thapar <vishal.thapar@ericsson.com>
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/InterfaceManager.java
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java

index a1cc4972589eee098b9d2b3cb32bca552c571e52..385e5cfcb3f196b0e01d3fa170db768f78d7cb67 100644 (file)
@@ -411,7 +411,7 @@ public class InterfaceManager extends AbstractDataChangeListener<Interface> impl
             org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder =
                             new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
             if (stateIf.isPresent()) {
-                stateIface = ifaceBuilder.setOperStatus(opStatus).build();
+                stateIface = ifaceBuilder.setOperStatus(opStatus).setKey(IfmUtil.getStateInterfaceKeyFromName(ifName)).build();
                 LOG.trace("Setting OperStatus for {} to {} in OPERATIONAL DS", ifName, opStatus);
                 asyncUpdate(LogicalDatastoreType.OPERATIONAL, id, stateIface, DEFAULT_CALLBACK);
             }
@@ -488,13 +488,12 @@ public class InterfaceManager extends AbstractDataChangeListener<Interface> impl
         Class<? extends InterfaceType> ifType = iface.getType();
         long dpn = this.getDpnForInterface(ifName);
         long portNo = this.getPortNumForInterface(iface).longValue();
-
         if (iface.isEnabled()) {
 
             if(ifType.isAssignableFrom(L2vlan.class)) {
                 IfL2vlan vlanIface = iface.getAugmentation(IfL2vlan.class);
-                long vlanVid = vlanIface.getVlanId();
                 LOG.trace("L2Vlan: {}",vlanIface);
+                long vlanVid = (vlanIface == null) ? 0 : vlanIface.getVlanId();
                 if (vlanVid != 0) {
                     listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}));
                     listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
@@ -536,7 +535,7 @@ public class InterfaceManager extends AbstractDataChangeListener<Interface> impl
         } catch (Exception e) {
             LOG.error("OFPort for Interface {} not found", iface.getName());
         }
-        return null;
+        return 0L;
     }
 
 }
index c9fee48716f391c0717b0f77db162d4be176c28f..ce11c4d4b19367b93502dac4193f2c93b98d2318 100644 (file)
@@ -214,7 +214,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         // check if vpn node is there or to be created
         InstanceIdentifier<VpnNexthops> id = idBuilder.build();
-        Optional<VpnNexthops> nexthops = read(LogicalDatastoreType.CONFIGURATION, id);
+        Optional<VpnNexthops> nexthops = read(LogicalDatastoreType.OPERATIONAL, id);
         if (!nexthops.isPresent()) {
             // create a new node
             VpnNexthops node = new VpnNexthopsBuilder().setKey(new VpnNexthopsKey(vpnId)).setVpnId(vpnId).build();
@@ -240,7 +240,7 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         // check if dpn node is there or to be created
         InstanceIdentifier<TunnelNexthops> id = idBuilder.build();
-        Optional<TunnelNexthops> nexthops = read(LogicalDatastoreType.CONFIGURATION, id);
+        Optional<TunnelNexthops> nexthops = read(LogicalDatastoreType.OPERATIONAL, id);
         if (!nexthops.isPresent()) {
             // create a new node
             TunnelNexthops node = new TunnelNexthopsBuilder()
@@ -269,8 +269,8 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
         InstanceIdentifierBuilder<VpnNexthops> idBuilder = InstanceIdentifier.builder(L3nexthop.class)
                 .child(VpnNexthops.class, new VpnNexthopsKey(vpnId));
         InstanceIdentifier<VpnNexthops> id = idBuilder.build();
-        Optional<VpnNexthops> vpnNexthops = read(LogicalDatastoreType.CONFIGURATION, id);
-        if (!vpnNexthops.isPresent()) {
+        Optional<VpnNexthops> vpnNexthops = read(LogicalDatastoreType.OPERATIONAL, id);
+        if (vpnNexthops.isPresent()) {
 
             // get nexthops list for vpn
             List<VpnNexthop> nexthops = vpnNexthops.get().getVpnNexthop();
@@ -292,8 +292,8 @@ public class NexthopManager implements L3nexthopService, AutoCloseable {
 
         // check if vpn node is there 
         InstanceIdentifier<TunnelNexthops> id = idBuilder.build();
-        Optional<TunnelNexthops> dpnNexthops = read(LogicalDatastoreType.CONFIGURATION, id);
-        if (!dpnNexthops.isPresent()) {
+        Optional<TunnelNexthops> dpnNexthops = read(LogicalDatastoreType.OPERATIONAL, id);
+        if (dpnNexthops.isPresent()) {
             List<TunnelNexthop> nexthops = dpnNexthops.get().getTunnelNexthop();
             for (TunnelNexthop nexthop : nexthops) {
                 if (nexthop.getIpAddress().equals(ipAddress)) {