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