Search in sources :

Example 6 with KubernetesCluster

use of com.cloud.kubernetes.cluster.KubernetesCluster in project cloudstack by apache.

the class StartKubernetesClusterCmd method execute.

@Override
public void execute() throws ServerApiException, ConcurrentOperationException {
    final KubernetesCluster kubernetesCluster = validateRequest();
    try {
        if (!kubernetesClusterService.startKubernetesCluster(kubernetesCluster.getId(), false)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to start Kubernetes cluster ID: %d", getId()));
        }
        final KubernetesClusterResponse response = kubernetesClusterService.createKubernetesClusterResponse(kubernetesCluster.getId());
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } catch (CloudRuntimeException ex) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
    }
}
Also used : KubernetesClusterResponse(org.apache.cloudstack.api.response.KubernetesClusterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) KubernetesCluster(com.cloud.kubernetes.cluster.KubernetesCluster)

Example 7 with KubernetesCluster

use of com.cloud.kubernetes.cluster.KubernetesCluster in project cloudstack by apache.

the class CreateKubernetesClusterCmd method create.

@Override
public void create() throws CloudRuntimeException {
    try {
        KubernetesCluster cluster = kubernetesClusterService.createKubernetesCluster(this);
        if (cluster == null) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Kubernetes cluster");
        }
        setEntityId(cluster.getId());
        setEntityUuid(cluster.getUuid());
    } catch (CloudRuntimeException e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) KubernetesCluster(com.cloud.kubernetes.cluster.KubernetesCluster)

Example 8 with KubernetesCluster

use of com.cloud.kubernetes.cluster.KubernetesCluster in project cloudstack by apache.

the class ScaleKubernetesClusterCmd method getEventDescription.

@Override
public String getEventDescription() {
    String description = "Scaling Kubernetes cluster";
    KubernetesCluster cluster = _entityMgr.findById(KubernetesCluster.class, getId());
    if (cluster != null) {
        description += String.format(" ID: %s", cluster.getUuid());
    } else {
        description += String.format(" ID: %d", getId());
    }
    return description;
}
Also used : KubernetesCluster(com.cloud.kubernetes.cluster.KubernetesCluster)

Aggregations

KubernetesCluster (com.cloud.kubernetes.cluster.KubernetesCluster)8 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 KubernetesSupportedVersion (com.cloud.kubernetes.version.KubernetesSupportedVersion)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 UserVm (com.cloud.uservm.UserVm)1 KubernetesClusterResponse (org.apache.cloudstack.api.response.KubernetesClusterResponse)1