Search in sources :

Example 1 with KubernetesClusterResponse

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

the class ScaleKubernetesClusterCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ServerApiException, ConcurrentOperationException {
    try {
        if (!kubernetesClusterService.scaleKubernetesCluster(this)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to scale Kubernetes cluster ID: %d", getId()));
        }
        final KubernetesClusterResponse response = kubernetesClusterService.createKubernetesClusterResponse(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)

Example 2 with KubernetesClusterResponse

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

the class UpgradeKubernetesClusterCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ServerApiException, ConcurrentOperationException {
    try {
        if (!kubernetesClusterService.upgradeKubernetesCluster(this)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, String.format("Failed to upgrade Kubernetes cluster ID: %d", getId()));
        }
        final KubernetesClusterResponse response = kubernetesClusterService.createKubernetesClusterResponse(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)

Example 3 with KubernetesClusterResponse

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

the class ListKubernetesClustersCmd method execute.

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

Example 4 with KubernetesClusterResponse

use of org.apache.cloudstack.api.response.KubernetesClusterResponse 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 5 with KubernetesClusterResponse

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

the class CreateKubernetesClusterCmd method execute.

@Override
public void execute() {
    try {
        if (!kubernetesClusterService.startKubernetesCluster(getEntityId(), true)) {
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start Kubernetes cluster");
        }
        KubernetesClusterResponse response = kubernetesClusterService.createKubernetesClusterResponse(getEntityId());
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } catch (CloudRuntimeException e) {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
    }
}
Also used : KubernetesClusterResponse(org.apache.cloudstack.api.response.KubernetesClusterResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException)

Aggregations

KubernetesClusterResponse (org.apache.cloudstack.api.response.KubernetesClusterResponse)7 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)5 ServerApiException (org.apache.cloudstack.api.ServerApiException)5 Project (com.cloud.projects.Project)2 Account (com.cloud.user.Account)2 UserAccount (com.cloud.user.UserAccount)2 ArrayList (java.util.ArrayList)2 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 Domain (com.cloud.domain.Domain)1 KubernetesCluster (com.cloud.kubernetes.cluster.KubernetesCluster)1 KubernetesSupportedVersionVO (com.cloud.kubernetes.version.KubernetesSupportedVersionVO)1 IPAddressVO (com.cloud.network.dao.IPAddressVO)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 ServiceOfferingVO (com.cloud.service.ServiceOfferingVO)1 VMTemplateVO (com.cloud.storage.VMTemplateVO)1 Ternary (com.cloud.utils.Ternary)1 Filter (com.cloud.utils.db.Filter)1 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1