X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fk8s_juju_conn.py;h=85e24f2c32c806753256d0b554ea181f186b85a8;hp=db34994260e5284034c671b5e2e6394109ad5129;hb=c4da25cc55411e6cea1e83d29c206bce421f0728;hpb=5ab1064304b993ea6364b5d932c5c0cb7434cfb7 diff --git a/n2vc/k8s_juju_conn.py b/n2vc/k8s_juju_conn.py index db34994..85e24f2 100644 --- a/n2vc/k8s_juju_conn.py +++ b/n2vc/k8s_juju_conn.py @@ -303,6 +303,7 @@ class K8sJujuConnector(K8sConnector): self, cluster_uuid: str, kdu_model: str, + kdu_instance: str, atomic: bool = True, timeout: float = 1800, params: dict = None, @@ -314,6 +315,7 @@ class K8sJujuConnector(K8sConnector): :param cluster_uuid str: The UUID of the cluster to install to :param kdu_model str: The name or path of a bundle to install + :param kdu_instance: Kdu instance name :param atomic bool: If set, waits until the model is active and resets the cluster on failure. :param timeout int: The time, in seconds, to wait for the install @@ -341,11 +343,6 @@ class K8sJujuConnector(K8sConnector): os.chdir(new_workdir) bundle = "local:{}".format(kdu_model) - if kdu_name: - kdu_instance = "{}-{}".format(kdu_name, db_dict["filter"]["_id"]) - else: - kdu_instance = db_dict["filter"]["_id"] - self.log.debug("Checking for model named {}".format(kdu_instance)) # Create the new model @@ -377,7 +374,7 @@ class K8sJujuConnector(K8sConnector): bundle, model_name=kdu_instance, wait=atomic, timeout=timeout ) os.chdir(previous_workdir) - return kdu_instance + return True async def instances_list(self, cluster_uuid: str) -> list: """ @@ -804,3 +801,13 @@ class K8sJujuConnector(K8sConnector): base64.b64decode(token).decode("utf-8"), base64.b64decode(client_certificate_data).decode("utf-8"), ) + + @staticmethod + def generate_kdu_instance_name(**kwargs): + db_dict = kwargs.get("db_dict") + kdu_name = kwargs.get("kdu_name", None) + if kdu_name: + kdu_instance = "{}-{}".format(kdu_name, db_dict["filter"]["_id"]) + else: + kdu_instance = db_dict["filter"]["_id"] + return kdu_instance