Table 21 ecmp flow not updated correctly
[netvirt.git] / fibmanager / api / src / main / java / org / opendaylight / netvirt / fibmanager / api / FibHelper.java
index b6297843087ea63d299d66e038f49daaa217e10a..8d6e822072be7531792e50e03387a8328926dd19 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netvirt.fibmanager.api;
 
 import static java.util.Comparator.comparing;
@@ -19,7 +18,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.stream.Collectors;
-import javax.annotation.Nullable;
+import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
@@ -35,12 +34,15 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev15033
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
 
 public final class FibHelper {
+    private FibHelper() {
 
-    private FibHelper() { }
+    }
 
-    public static RoutePaths buildRoutePath(String nextHop, Long label) {
+    public static RoutePaths buildRoutePath(String nextHop, Uint32 label) {
         RoutePathsBuilder builder = new RoutePathsBuilder()
                 .withKey(new RoutePathsKey(nextHop))
                 .setNexthopAddress(nextHop);
@@ -61,7 +63,7 @@ public final class FibHelper {
                 .setRoutePaths(routePaths).setOrigin(origin.getValue()).setParentVpnRd(parentVpnRd);
     }
 
-    public static VrfEntryBuilder getVrfEntryBuilder(String prefix, long label, String nextHop, RouteOrigin origin,
+    public static VrfEntryBuilder getVrfEntryBuilder(String prefix, Uint32 label, String nextHop, RouteOrigin origin,
             @Nullable String parentVpnRd) {
         if (nextHop != null) {
             RoutePaths routePath = buildRoutePath(nextHop, label);
@@ -71,7 +73,7 @@ public final class FibHelper {
         }
     }
 
-    public static VrfEntryBuilder getVrfEntryBuilder(VrfEntry vrfEntry, long label,
+    public static VrfEntryBuilder getVrfEntryBuilder(VrfEntry vrfEntry, Uint32 label,
             List<String> nextHopList, RouteOrigin origin, @Nullable String parentvpnRd) {
         List<RoutePaths> routePaths =
                 nextHopList.stream().map(nextHop -> buildRoutePath(nextHop, label))
@@ -88,13 +90,6 @@ public final class FibHelper {
         return idBuilder.build();
     }
 
-    public static boolean isControllerManagedRoute(RouteOrigin routeOrigin) {
-        return routeOrigin == RouteOrigin.STATIC
-                || routeOrigin == RouteOrigin.CONNECTED
-                || routeOrigin == RouteOrigin.LOCAL
-                || routeOrigin == RouteOrigin.INTERVPN;
-    }
-
     public static boolean isControllerManagedNonInterVpnLinkRoute(RouteOrigin routeOrigin) {
         return routeOrigin == RouteOrigin.STATIC
                 || routeOrigin == RouteOrigin.CONNECTED
@@ -116,12 +111,6 @@ public final class FibHelper {
         }
     }
 
-    public static InstanceIdentifier<RoutePaths> getRoutePathsIdentifier(String rd, String prefix, String nh) {
-        return InstanceIdentifier.builder(FibEntries.class)
-                .child(VrfTables.class,new VrfTablesKey(rd)).child(VrfEntry.class,new VrfEntryKey(prefix))
-                .child(RoutePaths.class, new RoutePathsKey(nh)).build();
-    }
-
     public static List<String> getNextHopListFromRoutePaths(final VrfEntry vrfEntry) {
         List<RoutePaths> routePaths = vrfEntry.getRoutePaths();
         if (routePaths == null || routePaths.isEmpty()) {
@@ -272,25 +261,6 @@ public final class FibHelper {
         return val;
     }
 
-    /**This methode return the bytes representation from an IP.
-     * @param ipBigInteger value integer of IP to convert
-     * @param isIpv4 if is ipv4 setup to true if ipv6 setup to false
-     * @return byte[] which contained the representation of bytes from th ip value
-     */
-    public static byte[] unpackBigInteger(BigInteger ipBigInteger, boolean isIpv4) {
-        int sizeBloc = 4;
-        if (!isIpv4) {
-            sizeBloc = 128 / 8;// if ipv6 size of dataIP is 128 bits
-        }
-        byte[] res = new byte[sizeBloc];
-        for (int i = 0 ; i < sizeBloc ; i++) {
-            BigInteger bigInt = ipBigInteger.shiftRight(i * 8);
-            bigInt = bigInt.and(BigInteger.valueOf(0xFF));
-            res[sizeBloc - 1 - i] = bigInt.byteValue();
-        }
-        return res;
-    }
-
     /**get the bits cache mask of net for a ip version type.
      * @param ipVersion version of ip must be 4 or 6
      * @param mask the lengh of the mask of net as 24 from this representation 10.1.1.0/24 or 64 for 2001::1/64
@@ -312,4 +282,8 @@ public final class FibHelper {
         }
         return bb;
     }
+
+    public static String getJobKeyForDcGwLoadBalancingGroup(Uint64 dpnId) {
+        return new StringBuilder().append("NextHopManager").append(dpnId).toString();
+    }
 }