From b891d380b72fbf9be56525070abe3dc7cd8d77bc Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 8 Feb 2024 14:11:51 +0100 Subject: [PATCH] Feature 11014: enable option kdu_reset_values to reset values for upgrade operation on helm charts Change-Id: I2d5e8e1436b5be3fcf9d7fd965338df51feb009a Signed-off-by: garciadeblas --- osm_lcm/ns.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index ea57400..6bc7a22 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -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, -- 2.25.1