Fix 2280: Random IP's are geeting assigned for Dual stack NS when doing scaling-out... 31/14031/2
authorrahul <rahul.k4@tataelxsi.co.in>
Wed, 30 Aug 2023 09:18:01 +0000 (14:48 +0530)
committercubag <gcuba@whitestack.com>
Tue, 19 Mar 2024 23:12:24 +0000 (00:12 +0100)
https://osm.etsi.org/bugzilla/show_bug.cgi?id=2280

Change-Id: Ic190de376e975e31840217cdbf6548863dfe5a02
Signed-off-by: rahul <rahul.k4@tataelxsi.co.in>
(cherry picked from commit 72d90d9217ee99b8e05cfe345f59db28f6d54d93)

osm_lcm/ns.py

index 382f9dc..7de51c1 100644 (file)
@@ -23,6 +23,7 @@ import yaml
 import logging
 import logging.handlers
 import traceback
+import ipaddress
 import json
 from jinja2 import (
     Environment,
@@ -233,6 +234,18 @@ class NsLcm(LcmBase):
         if not isinstance(ip_mac, str):
             return ip_mac
         try:
+            next_ipv6 = None
+            next_ipv4 = None
+            dual_ip = ip_mac.split(";")
+            if len(dual_ip) == 2:
+                for ip in dual_ip:
+                    if ipaddress.ip_address(ip).version == 6:
+                        ipv6 = ipaddress.IPv6Address(ip)
+                        next_ipv6 = str(ipaddress.IPv6Address(int(ipv6) + 1))
+                    elif ipaddress.ip_address(ip).version == 4:
+                        ipv4 = ipaddress.IPv4Address(ip)
+                        next_ipv4 = str(ipaddress.IPv4Address(int(ipv4) + 1))
+                return [next_ipv4, next_ipv6]
             # try with ipv4 look for last dot
             i = ip_mac.rfind(".")
             if i > 0: