Search in sources :

Example 1 with KubernetesClusterConfigResponse

use of org.apache.cloudstack.api.response.KubernetesClusterConfigResponse in project cloudstack by apache.

the class GetKubernetesClusterConfigCmd method execute.

@Override
public void execute() throws ServerApiException {
    try {
        KubernetesClusterConfigResponse response = kubernetesClusterService.getKubernetesClusterConfig(this);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } catch (CloudRuntimeException e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : KubernetesClusterConfigResponse(org.apache.cloudstack.api.response.KubernetesClusterConfigResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Example 2 with KubernetesClusterConfigResponse

use of org.apache.cloudstack.api.response.KubernetesClusterConfigResponse in project cloudstack by apache.

the class KubernetesClusterManagerImpl method getKubernetesClusterConfig.

public KubernetesClusterConfigResponse getKubernetesClusterConfig(GetKubernetesClusterConfigCmd cmd) {
    if (!KubernetesServiceEnabled.value()) {
        logAndThrow(Level.ERROR, "Kubernetes Service plugin is disabled");
    }
    final Long clusterId = cmd.getId();
    KubernetesCluster kubernetesCluster = kubernetesClusterDao.findById(clusterId);
    if (kubernetesCluster == null) {
        throw new InvalidParameterValueException("Invalid Kubernetes cluster ID specified");
    }
    KubernetesClusterConfigResponse response = new KubernetesClusterConfigResponse();
    response.setId(kubernetesCluster.getUuid());
    response.setName(kubernetesCluster.getName());
    String configData = "";
    KubernetesClusterDetailsVO clusterDetailsVO = kubernetesClusterDetailsDao.findDetail(kubernetesCluster.getId(), "kubeConfigData");
    if (clusterDetailsVO != null && StringUtils.isNotEmpty(clusterDetailsVO.getValue())) {
        configData = new String(Base64.decodeBase64(clusterDetailsVO.getValue()));
    } else {
        String exceptionMessage = KubernetesCluster.State.Starting.equals(kubernetesCluster.getState()) ? String.format("Setup is in progress for Kubernetes cluster : %s, config not available at this moment", kubernetesCluster.getName()) : String.format("Config not found for Kubernetes cluster : %s", kubernetesCluster.getName());
        throw new CloudRuntimeException(exceptionMessage);
    }
    response.setConfigData(configData);
    response.setObjectName("clusterconfig");
    return response;
}
Also used : KubernetesClusterConfigResponse(org.apache.cloudstack.api.response.KubernetesClusterConfigResponse) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)2 KubernetesClusterConfigResponse (org.apache.cloudstack.api.response.KubernetesClusterConfigResponse)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)1 ServerApiException (org.apache.cloudstack.api.ServerApiException)1