+
+ /*
+ * For each hwvtep configuration, we need to configure Physical LocatorTable of hwvtep schema with
+ * destination IP and tunnel-type. The configuration needs to be done for both local endpoint as well as remote endpoint
+ */
+ public static void addTerminationPoints(WriteTransaction transaction,
+ List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<Node> globalNodeId,
+ IfTunnel ifTunnel) {
+ //InstanceIdentifier<TerminationPoint> localTEP =
+ // createLocalPhysicalLocatorEntryIfNotPresent(futures, dataBroker,transaction, ifTunnel, globalNodeId);
+ createRemotePhysicalLocatorEntry(transaction, futures, globalNodeId, ifTunnel.getTunnelDestination());
+ //InstanceIdentifier<Tunnels> tunnelsInstanceIdentifier = createTunnelTableEntry(transaction, physicalSwitchNodeId, localTEP, remoteTEP);
+ }
+
+ private static InstanceIdentifier<TerminationPoint> createRemotePhysicalLocatorEntry(WriteTransaction transaction, List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<Node> nodeIid, IpAddress destIPAddress){
+ String remoteIp = destIPAddress.getIpv4Address().getValue();
+ LOG.debug("creating remote physical locator entry {}", remoteIp);
+ TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(remoteIp);
+ InstanceIdentifier<TerminationPoint> tpPath =
+ SouthboundUtils.createInstanceIdentifier(nodeIid, tpKey);
+ createPhysicalLocatorEntry(transaction, futures, tpPath, tpKey, destIPAddress);
+ return tpPath;
+ }
+
+
+ private static InstanceIdentifier<TerminationPoint> createLocalPhysicalLocatorEntryIfNotPresent(List<ListenableFuture<Void>> futures,
+ DataBroker dataBroker,
+ WriteTransaction transaction,
+ IfTunnel ifTunnel,
+ InstanceIdentifier<Node> nodeIid){
+ String localIp = ifTunnel.getTunnelSource().getIpv4Address().getValue();
+ LOG.debug("creating local physical locator entry {}", localIp);
+ TerminationPointKey tpKey = SouthboundUtils.getTerminationPointKey(localIp);
+ InstanceIdentifier<TerminationPoint> tpPath =
+ SouthboundUtils.createInstanceIdentifier(nodeIid, tpKey);
+ // if local tep is not present, create it
+ TerminationPoint terminationPoint = SouthboundUtils.getTEPFromConfigDS(tpPath, dataBroker);
+ if(terminationPoint == null) {
+ createPhysicalLocatorEntry(transaction, futures, tpPath, tpKey, ifTunnel.getTunnelSource());
+ }
+ return tpPath;
+ }
+
+ /*
+ * This method writes the termination end point details to the topology Config DS
+ */
+ private static void createPhysicalLocatorEntry(WriteTransaction transaction, List<ListenableFuture<Void>> futures,
+ InstanceIdentifier<TerminationPoint> tpPath, TerminationPointKey terminationPointKey,
+ IpAddress destIPAddress){
+ TerminationPointBuilder tpBuilder = new TerminationPointBuilder();
+ HwvtepPhysicalLocatorAugmentationBuilder tpAugmentationBuilder =
+ new HwvtepPhysicalLocatorAugmentationBuilder();
+ tpBuilder.setKey(terminationPointKey);
+ tpBuilder.setTpId(terminationPointKey.getTpId());
+ tpAugmentationBuilder.setEncapsulationType(EncapsulationTypeVxlanOverIpv4.class);
+ SouthboundUtils.setDstIp(tpAugmentationBuilder, destIPAddress);
+ tpBuilder.addAugmentation(HwvtepPhysicalLocatorAugmentation.class, tpAugmentationBuilder.build());
+ LOG.debug("creating physical locator entry for {}", terminationPointKey);
+ transaction.put(LogicalDatastoreType.CONFIGURATION,
+ tpPath, tpBuilder.build(), true);
+ }