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());
}
}
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;
}
Aggregations