COE : Use cluster-id instead of namespace 48/78048/4
authorFaseela K <faseela.k@ericsson.com>
Thu, 22 Nov 2018 13:16:01 +0000 (18:46 +0530)
committerSam Hague <shague@redhat.com>
Wed, 28 Nov 2018 15:59:23 +0000 (15:59 +0000)
cluster-id is the unique id for a k8s cluster,
and all pods in a cluster should be able to communicate
to each other.

JIRA: COE-19

Change-Id: I13375049814d39a2e45503d99b5912ec404f0fee
Signed-off-by: Faseela K <faseela.k@ericsson.com>
coe/impl/src/main/java/org/opendaylight/netvirt/coe/listeners/PodListener.java
coe/impl/src/main/java/org/opendaylight/netvirt/coe/utils/CoeUtils.java

index dee09b34fa0b9835effed6c26dddb95a53e241a3..2aa0b5bd9a05873acecea08708209d41328461e8 100644 (file)
@@ -171,12 +171,12 @@ public class PodListener implements DataTreeChangeListener<Pods> {
         @Override
         public List<ListenableFuture<Void>> call() {
             LOG.trace("Adding Pod : {}", podInterface);
-            String interfaceName = CoeUtils.buildInterfaceName(pods.getNetworkNS(), pods.getName());
+            String interfaceName = CoeUtils.buildInterfaceName(pods.getClusterId().getValue(), pods.getName());
             List<ListenableFuture<Void>> futures = new ArrayList<>();
             futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx ->  {
                 String nodeIp = pods.getHostIpAddress().stringValue();
                 ElanInstance elanInstance = CoeUtils.createElanInstanceForTheFirstPodInTheNetwork(
-                        pods.getNetworkNS(), nodeIp, podInterface, tx);
+                        pods.getClusterId().getValue(), nodeIp, podInterface, tx);
                 LOG.info("interface creation for pod {}", interfaceName);
                 String portInterfaceName = CoeUtils.createOfPortInterface(interfaceName, tx);
                 LOG.debug("Creating ELAN Interface for pod {}", interfaceName);
@@ -184,7 +184,7 @@ public class PodListener implements DataTreeChangeListener<Pods> {
                         elanInstance.getElanInstanceName(), tx);
                 LOG.debug("Creating VPN instance for namespace {}", pods.getNetworkNS());
                 List<String> rd = Arrays.asList("100:1");
-                CoeUtils.createVpnInstance(pods.getNetworkNS(), rd, null, null,
+                CoeUtils.createVpnInstance(pods.getClusterId().getValue(), rd, null, null,
                         VpnInstance.Type.L3, 0, IpVersionChoice.IPV4, tx);
             }));
             if (podInterface.getIpAddress() != null) {
@@ -210,7 +210,7 @@ public class PodListener implements DataTreeChangeListener<Pods> {
         @Override
         public List<ListenableFuture<Void>> call() {
             List<ListenableFuture<Void>> futures = new ArrayList<>();
-            String podInterfaceName = CoeUtils.buildInterfaceName(pods.getNetworkNS(), pods.getName());
+            String podInterfaceName = CoeUtils.buildInterfaceName(pods.getClusterId().getValue(), pods.getName());
             futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
                 LOG.trace("Deleting Pod : {}", podInterfaceName);
                 LOG.debug("Deleting VPN Interface for pod {}", podInterfaceName);
index f39994ec2d539592ed8bdf591c86acc84174dafa..c481a0d70f7f5175ea3f7f661f889d6ad1a8774a 100644 (file)
@@ -251,12 +251,12 @@ public final class CoeUtils {
     }
 
     public static ElanInstance
-        createElanInstanceForTheFirstPodInTheNetwork(String networkNS, String nodeIp,
+        createElanInstanceForTheFirstPodInTheNetwork(String clusterId, String nodeIp,
                                                  org.opendaylight.yang.gen.v1.urn.opendaylight.coe.northbound.pod
                                                          .rev170611.pod_attributes.Interface podInterface,
                                                  TypedReadWriteTransaction<Datastore.Configuration> wrtConfigTxn)
             throws ExecutionException, InterruptedException {
-        String elanInstanceName = buildElanInstanceName(nodeIp, networkNS);
+        String elanInstanceName = buildElanInstanceName(nodeIp, clusterId);
         InstanceIdentifier<ElanInstance> id = createElanInstanceIdentifier(elanInstanceName);
         ElanInstance existingElanInstance = wrtConfigTxn.read(id).get().orNull();
         if (existingElanInstance != null) {