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();
}
}
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();
}
}
Aggregations