Search in sources :

Example 1 with PaaSAlreadyDeployedException

use of alien4cloud.paas.exception.PaaSAlreadyDeployedException 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)

Aggregations

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