def node_info(ctx, cluster_name, node_name, org_name, vdc): """Display info about a node in a native Kubernetes provider cluster. \b Example vcd cse node info mycluster node-xxxx Display detailed information about node 'node-xxxx' in cluster 'mycluster'. """ CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}') try: client_utils.cse_restore_session(ctx) client = ctx.obj['client'] cluster = Cluster(client) if org_name is None and not client.is_sysadmin(): org_name = ctx.obj['profiles'].get('org_in_use') node_info = cluster.get_node_info(cluster_name, node_name, org_name, vdc) value_field_to_display_field = { 'name': 'Name', 'node_type': 'Node Type', 'ipAddress': 'IP Address', 'numberOfCpus': 'Number of CPUs', 'memoryMB': 'Memory MB', 'status': 'Status' } filtered_node_info = client_utils.filter_columns( node_info, value_field_to_display_field) stdout(filtered_node_info, ctx, sort_headers=False) CLIENT_LOGGER.debug(filtered_node_info) except Exception as e: stderr(e, ctx) CLIENT_LOGGER.error(str(e), exc_info=True)
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 list_ovdc(self): result = self._ovdc_api.list_ovdcs() value_field_to_display_field = { 'ovdc_name': 'Name', 'ovdc_id': 'ID', 'k8s_runtime': 'K8s Runtime' } return client_utils.filter_columns( result, value_field_to_display_field) # noqa: E501
def list_ovdc(self): for ovdc_list, has_more_results in self._ovdc_api.get_all_ovdcs(): value_field_to_display_field = { 'ovdc_name': 'Name', 'ovdc_id': 'ID', 'k8s_runtime': 'K8s Runtime' } yield client_utils.filter_columns( ovdc_list, value_field_to_display_field), has_more_results # noqa: E501
def list_templates(ctx, is_tkgm): """Display templates that can be used to deploy native/TKG clusters.""" CLIENT_LOGGER.debug(f'Executing command: {ctx.command_path}') try: client_utils.cse_restore_session(ctx) client = ctx.obj['client'] template = Template(client) result = template.get_templates(is_tkgm) CLIENT_LOGGER.debug(result) value_field_to_display_field = { 'name': 'Name', 'revision': 'Revision', 'catalog': 'Catalog', 'catalog_item': 'Catalog Item', 'description': 'Description' } filtered_result = client_utils.filter_columns( result, value_field_to_display_field) # noqa: E501 stdout(filtered_result, ctx, sort_headers=False) except Exception as e: stderr(e, ctx) CLIENT_LOGGER.error(str(e), exc_info=True)