Search in sources :

Example 1 with IllegalDeploymentStateException

use of alien4cloud.paas.exception.IllegalDeploymentStateException in project alien4cloud by alien4cloud.

the class AbstractPaaSProvider method deploy.

@Override
public void deploy(PaaSTopologyDeploymentContext deploymentContext, IPaaSCallback<?> callback) {
    String deploymentId = deploymentContext.getDeploymentPaaSId();
    DeploymentTopology deploymentTopology = deploymentContext.getDeploymentTopology();
    String yaml = archiveExportService.getYaml(new Csar(deploymentTopology.getArchiveName(), deploymentTopology.getArchiveVersion()), deploymentTopology, false, ToscaParser.LATEST_DSL);
    log.info("Attempting to deploy the following topology: " + yaml);
    try {
        providerLock.writeLock().lock();
        if (deploymentTopology.getProviderDeploymentProperties() != null) {
            // i.e : use / handle plugin deployment properties
            log.info("Topology deployment [" + deploymentTopology.getId() + "] for application [" + deploymentContext.getDeployment().getSourceName() + "]" + " and [" + deploymentTopology.getProviderDeploymentProperties().size() + "] deployment properties");
            log.info(deploymentTopology.getProviderDeploymentProperties().keySet().toString());
            for (String property : deploymentTopology.getProviderDeploymentProperties().keySet()) {
                log.info(property);
                if (deploymentTopology.getProviderDeploymentProperties().get(property) != null) {
                    log.info("[ " + property + " : " + deploymentTopology.getProviderDeploymentProperties().get(property) + "]");
                }
            }
        }
        DeploymentStatus deploymentStatus = getStatus(deploymentId, false);
        switch(deploymentStatus) {
            case DEPLOYED:
            case DEPLOYMENT_IN_PROGRESS:
            case UNDEPLOYMENT_IN_PROGRESS:
            case WARNING:
            case FAILURE:
                throw new PaaSAlreadyDeployedException("Topology [" + deploymentId + "] is in status [" + deploymentStatus + "] and cannot be deployed");
            case UNKNOWN:
                throw new IllegalDeploymentStateException("Topology [" + deploymentId + "] is in status [" + deploymentStatus + "] and cannot be deployed");
            case UNDEPLOYED:
                doDeploy(deploymentContext);
                break;
            default:
                throw new IllegalDeploymentStateException("Topology [" + deploymentId + "] is in illegal status [" + deploymentStatus + "] and cannot be deployed");
        }
    } finally {
        providerLock.writeLock().unlock();
    }
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) PaaSAlreadyDeployedException(alien4cloud.paas.exception.PaaSAlreadyDeployedException) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) IllegalDeploymentStateException(alien4cloud.paas.exception.IllegalDeploymentStateException) DeploymentStatus(alien4cloud.paas.model.DeploymentStatus)

Example 2 with IllegalDeploymentStateException

use of alien4cloud.paas.exception.IllegalDeploymentStateException in project alien4cloud by alien4cloud.

the class AbstractPaaSProvider method undeploy.

@Override
public void undeploy(PaaSDeploymentContext deploymentContext, IPaaSCallback<?> callback) {
    String deploymentId = deploymentContext.getDeploymentPaaSId();
    try {
        providerLock.writeLock().lock();
        DeploymentStatus deploymentStatus = getStatus(deploymentId, true);
        switch(deploymentStatus) {
            case UNDEPLOYMENT_IN_PROGRESS:
            case UNDEPLOYED:
                throw new PaaSNotYetDeployedException("Application [" + deploymentId + "] is in status [" + deploymentStatus + "] and cannot be undeployed");
            case UNKNOWN:
                throw new IllegalDeploymentStateException("Application [" + deploymentId + "] is in status [" + deploymentStatus + "] and cannot be undeployed");
            case DEPLOYMENT_IN_PROGRESS:
            case FAILURE:
            case DEPLOYED:
            case WARNING:
                doUndeploy(deploymentContext);
                callback.onSuccess(null);
                break;
            default:
                throw new IllegalDeploymentStateException("Application [" + deploymentId + "] is in illegal status [" + deploymentStatus + "] and cannot be undeployed");
        }
    } finally {
        providerLock.writeLock().unlock();
    }
}
Also used : PaaSNotYetDeployedException(alien4cloud.paas.exception.PaaSNotYetDeployedException) IllegalDeploymentStateException(alien4cloud.paas.exception.IllegalDeploymentStateException) DeploymentStatus(alien4cloud.paas.model.DeploymentStatus)

Aggregations

IllegalDeploymentStateException (alien4cloud.paas.exception.IllegalDeploymentStateException)2 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)2 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)1 PaaSAlreadyDeployedException (alien4cloud.paas.exception.PaaSAlreadyDeployedException)1 PaaSNotYetDeployedException (alien4cloud.paas.exception.PaaSNotYetDeployedException)1 Csar (org.alien4cloud.tosca.model.Csar)1