From: garciadeblas Date: Mon, 4 Aug 2025 07:15:48 +0000 (+0200) Subject: Feature 11057: Cluster management in Openshift-based infrastructures X-Git-Tag: v18.0.0~3 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F11%2F15311%2F2;p=osm%2Fosmclient.git Feature 11057: Cluster management in Openshift-based infrastructures Change-Id: I643f0689340ebfec93d020a52a2cd4b65a538fd9 Signed-off-by: garciadeblas --- diff --git a/osmclient/cli_commands/cluster.py b/osmclient/cli_commands/cluster.py index 2acbed2..83d5c65 100755 --- a/osmclient/cli_commands/cluster.py +++ b/osmclient/cli_commands/cluster.py @@ -15,6 +15,7 @@ import click from osmclient.cli_commands import common, utils +from osmclient.common.exceptions import ClientException from osmclient.common import print_output import logging import yaml @@ -50,6 +51,10 @@ logger = logging.getLogger("osmclient") default=True, help="bootstrap the cluster with Flux (prepare for GitOps) (default=True)", ) +@click.option("--config", default=None, help="cluster specific yaml configuration") +@click.option( + "--config_file", default=None, help="cluster specific yaml configuration file" +) @click.pass_context def cluster_create( ctx, @@ -62,7 +67,9 @@ def cluster_create( region_name, resource_group, bootstrap, - **kwargs + config, + config_file, + **kwargs, ): """creates a K8s cluster @@ -83,6 +90,18 @@ def cluster_create( if resource_group: cluster["resource_group"] = resource_group cluster["bootstrap"] = bootstrap + if config_file: + if config: + raise ClientException( + '"--config" option is incompatible with "--config_file" option' + ) + with open(config_file, "r", encoding="utf-8") as cf: + config = cf.read() + if config: + try: + cluster["config"] = yaml.safe_load(config) + except yaml.YAMLError as e: + raise ClientException(f"Error parsing YAML configuration: {e}") from e ctx.obj.cluster.create(name, content_dict=cluster) @@ -283,6 +302,12 @@ def cluster_get_kubeconfig(ctx, name, **kwargs): default=True, help="bootstrap the cluster with Flux (prepare for GitOps) (default=True)", ) +@click.option( + "--openshift", + required=False, + default=False, + help="flag to indicate that the cluster is Openshift-based (bootstrap is slightly different) (default=False)", +) @click.pass_context def cluster_register( ctx, @@ -291,6 +316,7 @@ def cluster_register( creds, description, bootstrap, + openshift, ): """registers a K8s cluster to OSM @@ -305,6 +331,8 @@ def cluster_register( if description: cluster["description"] = description cluster["bootstrap"] = bootstrap + if openshift: + cluster["openshift"] = openshift ctx.obj.cluster.register(name, cluster)