def cluster_list(request_data, request_context: ctx.RequestContext):
    """Request handler for cluster list operation.

    All brokers in the org do 'list cluster' operation.
    Post-process the result returned by the broker.
    Aggregate all the results into a list.

    Optional data and default values: org_name=None, ovdc_name=None

    (data validation handled in broker)

    :return: List
    """
    _raise_error_if_pks_not_enabled()

    pks_clusters_info = pks_broker_manager.list_clusters(
        request_data, request_context)
    common_cluster_properties = [
        'name', 'vdc', 'status', 'org_name', 'k8s_version', K8S_PROVIDER_KEY
    ]

    result = []
    for cluster_info in pks_clusters_info:
        filtered_cluster_info = \
            {k: cluster_info.get(k) for k in common_cluster_properties}
        result.append(filtered_cluster_info)

    return result
コード例 #2
0
def cluster_list(request_data, tenant_auth_token, is_jwt_token):
    """Request handler for cluster list operation.

    All (vCD/PKS) brokers in the org do 'list cluster' operation.
    Post-process the result returned by pks broker.
    Aggregate all the results into a list.

    Optional data and default values: org_name=None, ovdc_name=None

    (data validation handled in brokers)

    :return: List
    """
    vcd_broker = vcdbroker.VcdBroker(tenant_auth_token, is_jwt_token)
    vcd_clusters_info = vcd_broker.list_clusters(request_data)

    pks_clusters_info = []
    if utils.is_pks_enabled():
        pks_clusters_info = pks_broker_manager.list_clusters(
            request_data, tenant_auth_token, is_jwt_token)
    all_cluster_infos = vcd_clusters_info + pks_clusters_info

    common_cluster_properties = [
        'name', 'vdc', 'status', 'org_name', 'k8s_version', K8S_PROVIDER_KEY
    ]

    result = []
    for cluster_info in all_cluster_infos:
        filtered_cluster_info = \
            {k: cluster_info.get(k) for k in common_cluster_properties}
        result.append(filtered_cluster_info)

    return result