@click.command(
- name="cluster-get-credentials", short_help="get kubeconfig of a K8s cluster"
+ name="cluster-get-credentials", short_help="gets kubeconfig of a K8s cluster"
)
@click.argument("name")
@click.pass_context
def cluster_get_credentials(ctx, name, **kwargs):
- """updates a K8s cluster
+ """gets the kubeconfig file to access a K8s cluster
NAME: name or ID of the K8s cluster
"""
ctx.obj.cluster.get_credentials(name)
+# Alias for the cluster-get-credentials command
+@click.command(
+ name="cluster-get-kubeconfig", short_help="gets kubeconfig of a K8s cluster"
+)
+@click.argument("name")
+@click.pass_context
+def cluster_get_kubeconfig(ctx, name, **kwargs):
+ """Alias for the cluster-get-credentials command"""
+ ctx.invoke(cluster_get_credentials, name=name)
+
+
@click.command(name="cluster-register", short_help="registers a K8s cluster to OSM")
@click.argument("name")
@click.option(
cli_osm.add_command(cluster.cluster_show)
cli_osm.add_command(cluster.cluster_update)
cli_osm.add_command(cluster.cluster_get_credentials)
+ cli_osm.add_command(cluster.cluster_get_kubeconfig)
cli_osm.add_command(cluster.cluster_register)
cli_osm.add_command(netslice_instance.nsi_create1)
def get_credentials(self, name):
"""
- Gets and shows an individual Generic OSM API Object
- from the list of all objects of the same kind
+ Gets the kubeconfig file of a Kubernetes cluster
"""
self._logger.debug("")
item = self.get(name)
_, resp = self._http.get2_cmd(f"{self._apiBase}/{item['_id']}/get_creds")
if resp:
resp = json.loads(resp)
+ # TODO: loop to check if the credentials were populated in the db
item = self.get(name)
print(
yaml.safe_dump(
except Exception as e:
raise ClientException(f"{e}: unexpected response from server - {resp}")
- def register_cluster(self, name, cluster):
+ def register(self, name, cluster):
"""
Registers a K8s cluster
"""