def _get_cluster_info(self, cluster_name): """Get the details of a cluster with a given name in PKS environment. :param str cluster_name: Name of the cluster :return: Details of the cluster. :rtype: dict """ cluster_api = ClusterApi(api_client=self.pks_client) LOGGER.debug(f"Sending request to PKS: {self.pks_host_uri} to get " f"details of cluster with name: {cluster_name}") try: cluster = cluster_api.get_cluster(cluster_name=cluster_name) except ApiException as err: LOGGER.debug(f"Getting cluster info on {cluster_name} failed with " f"error:\n {err}") raise PksServerError(err.status, err.body) cluster_dict = cluster.to_dict() cluster_params_dict = cluster_dict.pop('parameters') cluster_dict.update(cluster_params_dict) LOGGER.debug(f"Received response from PKS: {self.pks_host_uri} on " f"cluster: {cluster_name} with details: {cluster_dict}") return cluster_dict
def get_cluster_info(self, name): """Get the details of a cluster with a given name in PKS environment. :param str name: Name of the cluster :return: Details of the cluster. :rtype: dict """ result = {} result['body'] = [] result['status_code'] = OK cluster_api = ClusterApi(api_client=self.pks_client) LOGGER.debug(f'Sending request to PKS: {self.host} to get details' f' of cluster with name: {name}') cluster = cluster_api.get_cluster(cluster_name=name) cluster_dict = cluster.to_dict() cluster_params_dict = cluster_dict.pop('parameters') cluster_dict.update(cluster_params_dict) LOGGER.debug(f'Received response from PKS: {self.host} on cluster:' f' {name} with details: {cluster_dict}') result['body'] = cluster_dict return result