Search in sources :

Example 1 with KubernetesCluster

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

the class KubernetesClusterActionWorker method attachIsoKubernetesVMs.

protected void attachIsoKubernetesVMs(List<UserVm> clusterVMs, final KubernetesSupportedVersion kubernetesSupportedVersion) throws CloudRuntimeException {
    KubernetesSupportedVersion version = kubernetesSupportedVersion;
    if (kubernetesSupportedVersion == null) {
        version = kubernetesSupportedVersionDao.findById(kubernetesCluster.getKubernetesVersionId());
    }
    KubernetesCluster.Event failedEvent = KubernetesCluster.Event.OperationFailed;
    KubernetesCluster cluster = kubernetesClusterDao.findById(kubernetesCluster.getId());
    if (cluster != null && cluster.getState() == KubernetesCluster.State.Starting) {
        failedEvent = KubernetesCluster.Event.CreateFailed;
    }
    if (version == null) {
        logTransitStateAndThrow(Level.ERROR, String.format("Unable to find Kubernetes version for cluster : %s", kubernetesCluster.getName()), kubernetesCluster.getId(), failedEvent);
    }
    VMTemplateVO iso = templateDao.findById(version.getIsoId());
    if (iso == null) {
        logTransitStateAndThrow(Level.ERROR, String.format("Unable to attach ISO to Kubernetes cluster : %s. Binaries ISO not found.", kubernetesCluster.getName()), kubernetesCluster.getId(), failedEvent);
    }
    if (!iso.getFormat().equals(Storage.ImageFormat.ISO)) {
        logTransitStateAndThrow(Level.ERROR, String.format("Unable to attach ISO to Kubernetes cluster : %s. Invalid Binaries ISO.", kubernetesCluster.getName()), kubernetesCluster.getId(), failedEvent);
    }
    if (!iso.getState().equals(VirtualMachineTemplate.State.Active)) {
        logTransitStateAndThrow(Level.ERROR, String.format("Unable to attach ISO to Kubernetes cluster : %s. Binaries ISO not active.", kubernetesCluster.getName()), kubernetesCluster.getId(), failedEvent);
    }
    for (UserVm vm : clusterVMs) {
        try {
            templateService.attachIso(iso.getId(), vm.getId(), true);
            if (LOGGER.isInfoEnabled()) {
                LOGGER.info(String.format("Attached binaries ISO for VM : %s in cluster: %s", vm.getDisplayName(), kubernetesCluster.getName()));
            }
        } catch (CloudRuntimeException ex) {
            logTransitStateAndThrow(Level.ERROR, String.format("Failed to attach binaries ISO for VM : %s in the Kubernetes cluster name: %s", vm.getDisplayName(), kubernetesCluster.getName()), kubernetesCluster.getId(), failedEvent, ex);
        }
    }
}
Also used : KubernetesSupportedVersion(com.cloud.kubernetes.version.KubernetesSupportedVersion) UserVm(com.cloud.uservm.UserVm) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) VMTemplateVO(com.cloud.storage.VMTemplateVO) KubernetesCluster(com.cloud.kubernetes.cluster.KubernetesCluster)

Example 2 with KubernetesCluster

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

the class StopKubernetesClusterCmd method getEventDescription.

@Override
public String getEventDescription() {
    String description = "Stopping 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)

Example 3 with KubernetesCluster

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

the class StartKubernetesClusterCmd method getEventDescription.

@Override
public String getEventDescription() {
    String description = "Starting 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)

Example 4 with KubernetesCluster

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

the class UpgradeKubernetesClusterCmd method getEventDescription.

@Override
public String getEventDescription() {
    String description = "Upgrading 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)

Example 5 with KubernetesCluster

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

the class DeleteKubernetesClusterCmd method getEventDescription.

@Override
public String getEventDescription() {
    String description = "Deleting 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