Bug_Fix-2348 NS Update getting failed while using SFC feature
[osm/LCM.git] / osm_lcm / ns.py
index 76f0bf5..2fecb5d 100644 (file)
@@ -23,6 +23,7 @@ import yaml
 import logging
 import logging.handlers
 import traceback
+import ipaddress
 import json
 from jinja2 import (
     Environment,
@@ -221,6 +222,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:
@@ -5893,6 +5906,12 @@ class NsLcm(LcmBase):
                                     )
                                 )
 
+                        step = "Checking whether the descriptor has SFC"
+                        if db_nsr.get("nsd", {}).get("vnffgd"):
+                            raise LcmException(
+                                "Ns update is not allowed for NS with SFC"
+                            )
+
                         # There is no change in the charm package, then redeploy the VNF
                         # based on new descriptor
                         step = "Redeploying VNF"
@@ -6273,6 +6292,10 @@ class NsLcm(LcmBase):
             old_operational_status = db_nsr["operational-status"]
             old_config_status = db_nsr["config-status"]
 
+            step = "Checking whether the descriptor has SFC"
+            if db_nsr.get("nsd", {}).get("vnffgd"):
+                raise LcmException("Scaling is not allowed for NS with SFC")
+
             step = "Parsing scaling parameters"
             db_nsr_update["operational-status"] = "scaling"
             self.update_db_2("nsrs", nsr_id, db_nsr_update)