)
# sync fs
- self.fs.reverse_sync(from_path=cluster_uuid)
+ self.fs.reverse_sync(from_path=cluster_id)
- async def repo_update(self, cluster_uuid: str, name: str, repo_type: str = "chart"):
+ async def repo_update(self, cluster_id: str, name: str, repo_type: str = "chart"):
self.log.debug(
- "Cluster {}, updating {} repository {}".format(
- cluster_uuid, repo_type, name
- )
+ "Cluster {}, updating {} repository {}".format(cluster_id, repo_type, name)
)
# init_env
paths, env = self._init_paths_env(
- cluster_name=cluster_uuid, create_if_not_exist=True
+ cluster_name=cluster_id, create_if_not_exist=True
)
# sync local dir
- self.fs.sync(from_path=cluster_uuid)
+ self.fs.sync(from_path=cluster_id)
# helm repo update
command = "{} repo update {}".format(self._helm_command, name)
)
# sync fs
- self.fs.reverse_sync(from_path=cluster_uuid)
+ self.fs.reverse_sync(from_path=cluster_id)
async def repo_list(self, cluster_uuid: str) -> list:
"""
return []
async def repo_remove(self, cluster_uuid: str, name: str):
-
_, cluster_id = self._get_namespace_cluster_id(cluster_uuid)
self.log.debug("remove {} repositories for cluster {}".format(name, cluster_id))
repo = self._split_repo(kdu_model)
if repo:
- self.repo_update(cluster_id, repo)
+ await self.repo_update(cluster_id, repo)
command = self._get_install_command(
kdu_model,
output, rc = exec_task.result()
else:
-
output, rc = await self._local_async_exec(
command=command, raise_exception_on_error=False, env=env
)
repo = self._split_repo(kdu_model)
if repo:
- self.repo_update(cluster_uuid, repo)
+ await self.repo_update(cluster_id, repo)
command = self._get_upgrade_command(
kdu_model,
self.log.debug("upgrading: {}".format(command))
if atomic:
-
# exec helm in a task
exec_task = asyncio.ensure_future(
coro_or_future=self._local_async_exec(
output, rc = exec_task.result()
else:
-
output, rc = await self._local_async_exec(
command=command, raise_exception_on_error=False, env=env
)
async def rollback(
self, cluster_uuid: str, kdu_instance: str, revision=0, db_dict: dict = None
):
-
_, cluster_id = self._get_namespace_cluster_id(cluster_uuid)
self.log.debug(
"rollback kdu_instance {} to revision {} from cluster {}".format(
async def get_service(
self, cluster_uuid: str, service_name: str, namespace: str
) -> object:
-
self.log.debug(
"get service, service_name: {}, namespace: {}, cluster_uuid: {}".format(
service_name, namespace, cluster_uuid
return status
async def values_kdu(self, kdu_model: str, repo_url: str = None) -> str:
-
self.log.debug(
"inspect kdu_model values {} from (optional) repo: {}".format(
kdu_model, repo_url
)
async def help_kdu(self, kdu_model: str, repo_url: str = None) -> str:
-
self.log.debug(
"inspect kdu_model {} readme.md from repo: {}".format(kdu_model, repo_url)
)
)
async def synchronize_repos(self, cluster_uuid: str):
-
self.log.debug("synchronize repos for cluster helm-id: {}".format(cluster_uuid))
try:
db_repo_ids = self._get_helm_chart_repos_ids(cluster_uuid)
encode_utf8: bool = False,
env: dict = None,
) -> (str, int):
-
command = K8sHelmBaseConnector._remove_multiple_spaces(command)
self.log.debug(
"Executing async local command: {}, env: {}".format(command, env)
encode_utf8: bool = False,
env: dict = None,
):
-
command1 = K8sHelmBaseConnector._remove_multiple_spaces(command1)
command2 = K8sHelmBaseConnector._remove_multiple_spaces(command2)
command = "{} | {}".format(command1, command2)
# params for use in -f file
# returns values file option and filename (in order to delete it at the end)
def _params_to_file_option(self, cluster_id: str, params: dict) -> (str, str):
-
if params and len(params) > 0:
self._init_paths_env(cluster_name=cluster_id, create_if_not_exist=True)
name = name + get_random_number()
return name.lower()
- async def _split_repo(self, kdu_model: str) -> str:
+ def _split_repo(self, kdu_model: str) -> str:
repo_name = None
idx = kdu_model.find("/")
if idx >= 0: