Feature 11014: enable option kdu_reset_values to reset values for upgrade operation... 24/14224/6
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Thu, 8 Feb 2024 13:11:51 +0000 (14:11 +0100)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Fri, 5 Jul 2024 05:49:25 +0000 (07:49 +0200)
Change-Id: I2d5e8e1436b5be3fcf9d7fd965338df51feb009a
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
osm_lcm/ns.py

index ea57400..6bc7a22 100644 (file)
@@ -5244,12 +5244,48 @@ class NsLcm(LcmBase):
                         del desc_params["kdu_atomic_upgrade"]
                     else:
                         atomic_upgrade = True
+                    # Type of upgrade: reset, reuse, reset_then_reuse
+                    reset_values = False
+                    reuse_values = False
+                    reset_then_reuse_values = False
+                    # If no option is specified, default behaviour is reuse_values
+                    # Otherwise, options will be parsed and used
+                    if (
+                        ("kdu_reset_values" not in desc_params)
+                        and ("kdu_reuse_values" not in desc_params)
+                        and ("kdu_reset_then_reuse_values" not in desc_params)
+                    ):
+                        reuse_values = True
+                    else:
+                        if desc_params.get("kdu_reset_values"):
+                            reset_values = desc_params.pop(
+                                "kdu_reset_values"
+                            ).lower() in ("yes", "true", "1")
+                        if desc_params.get("kdu_reuse_values"):
+                            reuse_values = desc_params.pop(
+                                "kdu_reuse_values"
+                            ).lower() in ("yes", "true", "1")
+                        if desc_params.get("kdu_reset_then_reuse_values"):
+                            reset_then_reuse_values = desc_params.get(
+                                "kdu_reset_then_reuse_values"
+                            ).lower() in ("yes", "true", "1")
+                        # Two true options are not possible
+                        if (
+                            sum([reset_values, reuse_values, reset_then_reuse_values])
+                            >= 2
+                        ):
+                            raise LcmException(
+                                "Cannot upgrade the KDU simultaneously with two true options to handle values"
+                            )
 
                     detailed_status = await asyncio.wait_for(
                         self.k8scluster_map[kdu["k8scluster-type"]].upgrade(
                             cluster_uuid=kdu.get("k8scluster-uuid"),
                             kdu_instance=kdu.get("kdu-instance"),
                             atomic=atomic_upgrade,
+                            reset_values=reset_values,
+                            reuse_values=reuse_values,
+                            reset_then_reuse_values=reset_then_reuse_values,
                             kdu_model=kdu_model,
                             params=desc_params,
                             db_dict=db_dict,