X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fconfighelpers%2FItmInternalTunnelAddWorker.java;h=9f2196434d279b5a08c28aeb9bc94c8ec5f081b1;hb=ad664a0c796d1b29f0f337a4ce0a26ce9b3c2238;hp=c7c5ae726bc7b3c9e6eefe17c3935605593ab4e8;hpb=338d547060c53eff8d0a13f94059b86d8b52bbca;p=vpnservice.git diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelAddWorker.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelAddWorker.java index c7c5ae72..9f219643 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelAddWorker.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelAddWorker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. + * Copyright (c) 2015, 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, @@ -64,7 +64,7 @@ public class ItmInternalTunnelAddWorker { WriteTransaction t = dataBroker.newWriteOnlyTransaction(); if( null == cfgdDpnList || cfgdDpnList.isEmpty()) { logger.error(" Build Tunnels was invoked with empty list"); - return null; + return futures; } for( DPNTEPsInfo dpn : cfgdDpnList) { @@ -147,24 +147,34 @@ public class ItmInternalTunnelAddWorker { logger.trace( "Wiring between source tunnel end points {}, destination tunnel end points {} " , srcte, dstte ); String interfaceName = srcte.getInterfaceName() ; Class tunType = srcte.getTunnelType(); - String ifDescription = srcte.getTunnelType().getName(); + String tunTypeStr = srcte.getTunnelType().getName(); // Form the trunk Interface Name - String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName,srcte.getIpAddress().getIpv4Address().getValue(), dstte.getIpAddress().getIpv4Address().getValue()) ; - IpAddress gwyIpAddress = ( srcte.getSubnetMask().equals(dstte.getSubnetMask()) ) ? null : srcte.getGwIpAddress() ; + String trunkInterfaceName = ItmUtils.getTrunkInterfaceName( idManagerService, interfaceName, + srcte.getIpAddress().getIpv4Address().getValue(), + dstte.getIpAddress().getIpv4Address().getValue(), + tunTypeStr) ; + IpAddress gatewayIpObj = new IpAddress("0.0.0.0".toCharArray()); + IpAddress gwyIpAddress = ( srcte.getSubnetMask().equals(dstte.getSubnetMask()) ) ? gatewayIpObj : srcte.getGwIpAddress() ; logger.debug( " Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, source IP - {}, destination IP - {} gateway IP - {}",trunkInterfaceName, interfaceName, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress ) ; - Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, true) ; + Boolean monitorEnabled = ItmUtils.readMonitoringStateFromDS(dataBroker); + Integer monitorInterval = ItmUtils.readMonitorIntervalfromDS(dataBroker); + if(monitorInterval == null) + monitorInterval = ITMConstants.DEFAULT_MONITOR_INTERVAL; + Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format( "%s %s",ItmUtils.convertTunnelTypetoString(srcte.getTunnelType()), "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress, srcte.getVLANID(), true, monitorEnabled, monitorInterval*1000); logger.debug( " Trunk Interface builder - {} ", iface ) ; InstanceIdentifier trunkIdentifier = ItmUtils.buildId(trunkInterfaceName); logger.debug( " Trunk Interface Identifier - {} ", trunkIdentifier ) ; logger.trace( " Writing Trunk Interface to Config DS {}, {} ", trunkIdentifier, iface ) ; t.merge(LogicalDatastoreType.CONFIGURATION, trunkIdentifier, iface, true); + ItmUtils.itmCache.addInterface(iface); // also update itm-state ds? InstanceIdentifier path = InstanceIdentifier.create( TunnelList.class) - .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId)); - InternalTunnel tnl = ItmUtils.buildInternalTunnel(srcDpnId, dstDpnId, trunkInterfaceName); + .child(InternalTunnel.class, new InternalTunnelKey( dstDpnId, srcDpnId, tunType)); + InternalTunnel tnl = ItmUtils.buildInternalTunnel(srcDpnId, dstDpnId, tunType, trunkInterfaceName); //ItmUtils.asyncUpdate(LogicalDatastoreType.CONFIGURATION, path, tnl, dataBroker, DEFAULT_CALLBACK); t.merge(LogicalDatastoreType.CONFIGURATION,path, tnl, true) ; + ItmUtils.itmCache.addInternalTunnel(tnl); return true; } }