Revert "Bug 1964 fixed: removed the variable cluster_uuid from init_env method"
This reverts commit 25a1392579da2e8e4789e0b8f35abbaa372fde08.
Change-Id: If90fe74a1d7d4b915bbb839ace19999403aa5548
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/n2vc/k8s_helm_conn.py b/n2vc/k8s_helm_conn.py
index b1ad379..f0cbb46 100644
--- a/n2vc/k8s_helm_conn.py
+++ b/n2vc/k8s_helm_conn.py
@@ -132,18 +132,19 @@
:param kwargs: Additional parameters (None yet)
:return: True if successful
"""
- self.log.debug("installing {} in cluster {}".format(kdu_model, cluster_uuid))
+ _, cluster_id = self._get_namespace_cluster_id(cluster_uuid)
+ self.log.debug("installing {} in cluster {}".format(kdu_model, cluster_id))
# sync local dir
- self.fs.sync(from_path=cluster_uuid)
+ self.fs.sync(from_path=cluster_id)
# init env, paths
paths, env = self._init_paths_env(
- cluster_name=cluster_uuid, create_if_not_exist=True
+ cluster_name=cluster_id, create_if_not_exist=True
)
await self._install_impl(
- cluster_uuid,
+ cluster_id,
kdu_model,
paths,
env,
@@ -157,7 +158,7 @@
)
# sync fs
- self.fs.reverse_sync(from_path=cluster_uuid)
+ self.fs.reverse_sync(from_path=cluster_id)
self.log.debug("Returning kdu_instance {}".format(kdu_instance))
return True
@@ -342,13 +343,15 @@
else:
self.log.info("Helm client already initialized")
- repo_list = await self.repo_list(cluster_id)
+ # remove old stable repo and add new one
+ cluster_uuid = "{}:{}".format(namespace, cluster_id)
+ repo_list = await self.repo_list(cluster_uuid)
for repo in repo_list:
if repo["name"] == "stable" and repo["url"] != self._stable_repo_url:
self.log.debug("Add new stable repo url: {}")
- await self.repo_remove(cluster_id, "stable")
+ await self.repo_remove(cluster_uuid, "stable")
if self._stable_repo_url:
- await self.repo_add(cluster_id, "stable", self._stable_repo_url)
+ await self.repo_add(cluster_uuid, "stable", self._stable_repo_url)
break
return n2vc_installed_sw
@@ -405,13 +408,8 @@
output, _rc = await self._local_async_exec(
command=command, raise_exception_on_error=False, env=env
)
- command = (
- "{} --kubeconfig={} --namespace {} delete serviceaccount/{}".format(
- self.kubectl_command,
- paths["kube_config"],
- namespace,
- self.service_account,
- )
+ command = "{} --kubeconfig={} --namespace kube-system delete serviceaccount/{}".format(
+ self.kubectl_command, paths["kube_config"], self.service_account
)
output, _rc = await self._local_async_exec(
command=command, raise_exception_on_error=False, env=env