X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=vpnservice.git;a=blobdiff_plain;f=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fimpl%2FItmUtils.java;fp=itm%2Fitm-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fvpnservice%2Fitm%2Fimpl%2FItmUtils.java;h=0750ea479213dc7f63648f453a25b4f7aa7fc320;hp=74d143c4da4ab149b1846813865d27597ed182ae;hb=de28c9eeb14ae5e5f65bc4621f3802ee4f831d49;hpb=7fd91ca847eaebfa14b0da26e986641be438fdae diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmUtils.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmUtils.java index 74d143c4..0750ea47 100644 --- a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmUtils.java +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmUtils.java @@ -40,6 +40,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPointsBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPointsKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.external.tunnel.list.ExternalTunnelKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey; import org.opendaylight.vpnservice.itm.globals.ITMConstants; import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; @@ -169,17 +175,30 @@ public class ItmUtils { } public static Interface buildTunnelInterface(BigInteger dpn, String ifName, String desc, boolean enabled, Class tunType, - IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp) { + IpAddress localIp, IpAddress remoteIp, IpAddress gatewayIp, boolean internal) { InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName) .setDescription(desc).setEnabled(enabled).setType(Tunnel.class); ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build(); builder.addAugmentation(ParentRefs.class, parentRefs); IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(remoteIp).setTunnelGateway(gatewayIp).setTunnelSource(localIp) - .setTunnelInterfaceType( tunType).build(); + .setTunnelInterfaceType( tunType).setInternal(internal).build(); builder.addAugmentation(IfTunnel.class, tunnel); return builder.build(); } + public static InternalTunnel buildInternalTunnel( BigInteger srcDpnId, BigInteger dstDpnId, String trunkInterfaceName) { + InternalTunnel tnl = new InternalTunnelBuilder().setKey(new InternalTunnelKey(srcDpnId, dstDpnId)) + .setDestinationDPN(dstDpnId) + .setSourceDPN(srcDpnId) + .setTunnelInterfaceName(trunkInterfaceName).build(); + return tnl ; + } + + public static ExternalTunnel buildExternalTunnel( BigInteger srcDpnId, IpAddress dstIp, String trunkInterfaceName) { + ExternalTunnel extTnl = new ExternalTunnelBuilder().setKey(new ExternalTunnelKey(dstIp, srcDpnId)).setSourceDPN(srcDpnId).setDestinationIP(dstIp).setTunnelInterfaceName(trunkInterfaceName).build(); + return extTnl ; + } + public static List getTunnelMeshInfo(DataBroker dataBroker) { List dpnTEPs= null ; @@ -227,4 +246,18 @@ public class ItmUtils { LOG.warn("Exception when getting Unique Id for key {}", idKey, e); } } + + public static List getDPNTEPListFromDPNId(DataBroker dataBroker, List dpnIds) { + List meshedDpnList = getTunnelMeshInfo(dataBroker) ; + List cfgDpnList = new ArrayList(); + if( null != meshedDpnList) { + for(BigInteger dpnId : dpnIds) { + for( DPNTEPsInfo teps : meshedDpnList ) { + if( dpnId.equals(teps.getDPNID())) + cfgDpnList.add( teps) ; + } + } + } + return cfgDpnList; + } }