def list_nodes(ctx, name, org, vdc): """Display nodes of a cluster that uses native Kubernetes provider. \b Example vcd cse node list mycluster Displays nodes in 'mycluster'. """ CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}') try: client_utils.cse_restore_session(ctx) client = ctx.obj['client'] if org is None and not client.is_sysadmin(): org = ctx.obj['profiles'].get('org_in_use') cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name, org=org, vdc=vdc) if cluster_info.get(K8S_PROVIDER_KEY) != K8sProvider.NATIVE: raise Exception("'node list' operation is not supported by non " "native clusters.") all_nodes = cluster_info['master_nodes'] + cluster_info['nodes'] value_field_to_display_field = { 'name': 'Name', 'ipAddress': 'IP Address', 'numberOfCpus': 'Number of CPUs', 'memoryMB': 'Memory MB' } filtered_nodes = client_utils.filter_columns(all_nodes, value_field_to_display_field) # noqa: E501 stdout(filtered_nodes, ctx, show_id=True, sort_headers=False) CLIENT_LOGGER.debug(all_nodes) except Exception as e: stderr(e, ctx) CLIENT_LOGGER.error(str(e), exc_info=True)
def cluster_info(ctx, name): try: client = ctx.obj['client'] cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name) stdout(cluster_info, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def list_nodes(ctx, name): try: client = ctx.obj['client'] cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name) all_nodes = cluster_info['master_nodes'] + cluster_info['nodes'] stdout(all_nodes, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def cluster_info(ctx, name): """Display info about a Kubernetes cluster.""" try: restore_session(ctx) client = ctx.obj['client'] cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name) stdout(cluster_info, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def list_nodes(ctx, name): """Display nodes in a Kubernetes cluster.""" try: restore_session(ctx) client = ctx.obj['client'] cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name) all_nodes = cluster_info['master_nodes'] + cluster_info['nodes'] stdout(all_nodes, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def cluster_info(ctx, name, org, vdc): """Display info about a Kubernetes cluster.""" try: restore_session(ctx) client = ctx.obj['client'] cluster = Cluster(client) if not client.is_sysadmin() and org is None: org = ctx.obj['profiles'].get('org_in_use') cluster_info = cluster.get_cluster_info(name, org=org, vdc=vdc) stdout(cluster_info, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def cluster_info(ctx, name, org, vdc): """Display info about a Kubernetes cluster.""" CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}') try: restore_session(ctx) client = ctx.obj['client'] cluster = Cluster(client) if not client.is_sysadmin() and org is None: org = ctx.obj['profiles'].get('org_in_use') cluster_info = cluster.get_cluster_info(name, org=org, vdc=vdc) stdout(cluster_info, ctx, show_id=True) CLIENT_LOGGER.debug(cluster_info) except Exception as e: stderr(e, ctx) CLIENT_LOGGER.error(str(e))
def list_nodes(ctx, name, org, vdc): """Display nodes of a cluster that uses native Kubernetes provider.""" try: restore_session(ctx) client = ctx.obj['client'] if org is None and not client.is_sysadmin(): org = ctx.obj['profiles'].get('org_in_use') cluster = Cluster(client) cluster_info = cluster.get_cluster_info(name, org=org, vdc=vdc) if cluster_info.get(K8S_PROVIDER_KEY) != K8sProvider.NATIVE: raise Exception("'node list' operation is not supported by non " "native clusters.") all_nodes = cluster_info['master_nodes'] + cluster_info['nodes'] stdout(all_nodes, ctx, show_id=True) except Exception as e: stderr(e, ctx)
def cluster_info(ctx, name, org, vdc, k8_runtime=None, cluster_id=None): """Display info about a Kubernetes cluster. \b Example vcd cse cluster info mycluster Display detailed information about cluster 'mycluster'. '--vdc' option can be used for faster command execution. \b vcd cse cluster info --id urn:vcloud:entity:cse:nativeCluster:1.0.0:0632c7c7-a613-427c-b4fc-9f1247da5561 Display cluster information about cluster with ID 'urn:vcloud:entity:cse:nativeCluster:1.0.0:0632c7c7-a613-427c-b4fc-9f1247da5561' (--id option is supported only for api version >= 35) """ # noqa: E501 CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}') try: if not (cluster_id or name): # --id is not required when working with api version 33 and 34 raise Exception( "Please specify cluster name (or) cluster Id. " "Note that '--id' flag is applicable for API versions >= 35 only." ) # noqa: E501 client_utils.cse_restore_session(ctx) if client_utils.is_cli_for_tkg_only(): if k8_runtime in [ shared_constants.ClusterEntityKind.NATIVE.value, shared_constants.ClusterEntityKind.TKG_PLUS.value ]: # noqa: E501 # Cannot run the command as cse cli is enabled only for native raise CseServerNotRunningError() k8_runtime = shared_constants.ClusterEntityKind.TKG.value client = ctx.obj['client'] cluster = Cluster(client, k8_runtime=k8_runtime) if not client.is_sysadmin() and org is None: org = ctx.obj['profiles'].get('org_in_use') result = cluster.get_cluster_info(name, cluster_id=cluster_id, org=org, vdc=vdc) stdout(result, ctx) CLIENT_LOGGER.debug(result) except Exception as e: stderr(e, ctx) CLIENT_LOGGER.error(str(e))