common.generic_show(callback=ctx.obj.cluster.get_both, name=name, format=output)
-@click.command(name="cluster-update", short_help="updates a K8s cluster")
+@click.command(
+ name="cluster-edit", short_help="updates name or description of a K8s cluster"
+)
@click.argument("name")
@click.option("--newname", help="New name for the K8s cluster")
@click.option("--description", help="human readable description")
@click.pass_context
-def cluster_update(ctx, name, newname, description, **kwargs):
- """updates a K8s cluster
+def cluster_edit(ctx, name, newname, description, **kwargs):
+ """updates the name or description of a K8s cluster
NAME: name or ID of the K8s cluster
"""
ctx.obj.cluster.scale(name, cluster_changes)
+@click.command(name="cluster-update", short_help="updates a K8s cluster")
+@click.argument("name")
+@click.option("--version", help="Kubernetes version")
+@click.option("--node-count", "-n", type=int, help="number of nodes")
+@click.option("--node-size", help="size of the worker nodes")
+@click.pass_context
+def cluster_update(ctx, name, version, node_count, node_size, **kwargs):
+ """updates the number of nodes, the version or the node size of a K8s cluster
+
+ NAME: name or ID of the K8s cluster
+ """
+ logger.debug("")
+ cluster_changes = {}
+ if version:
+ cluster_changes["k8s_version"] = version
+ if node_count:
+ cluster_changes["node_count"] = node_count
+ if node_size:
+ cluster_changes["node_size"] = node_size
+ ctx.obj.cluster.fullupdate(name, cluster_changes)
+
+
@click.command(
name="cluster-get-credentials", short_help="gets kubeconfig of a K8s cluster"
)
cli_osm.add_command(cluster.cluster_delete)
cli_osm.add_command(cluster.cluster_list)
cli_osm.add_command(cluster.cluster_show)
+ cli_osm.add_command(cluster.cluster_edit)
cli_osm.add_command(cluster.cluster_update)
cli_osm.add_command(cluster.cluster_upgrade)
cli_osm.add_command(cluster.cluster_scale)
endpoint_suffix = f"{item['_id']}/scale"
self.generic_operation(cluster_changes, endpoint_suffix=endpoint_suffix)
+ def fullupdate(self, name, cluster_changes):
+ """
+ Updates a K8s cluster (version, node size or node count)
+ """
+ self._logger.debug("")
+ item = self.get(name)
+ endpoint_suffix = f"{item['_id']}/update"
+ self.generic_operation(cluster_changes, endpoint_suffix=endpoint_suffix)
+
def list_both(self, filter=None):
"""List all clusters from both new and old APIs"""
self._logger.debug("")