use of alien4cloud.model.deployment.DeploymentTopology 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.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.
the class RuntimeController method getDeployedTopology.
/**
* Get runtime (deployed) topology of an application on a specific environment
*
* @param applicationId application id for which to get the topology
* @param applicationEnvironmentId application environment for which to get the topology through the version
* @return {@link RestResponse}<{@link TopologyDTO}> containing the requested runtime {@link Topology} and the
* {@link NodeType} related to his {@link NodeTemplate}s
*/
@ApiOperation(value = "Get runtime (deployed) topology of an application on a specific cloud.")
@RequestMapping(value = "/{applicationId:.+?}/environment/{applicationEnvironmentId:.+?}/topology", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<TopologyDTO> getDeployedTopology(@ApiParam(value = "Id of the application for which to get deployed topology.", required = true) @PathVariable String applicationId, @ApiParam(value = "Id of the environment for which to get deployed topology.", required = true) @PathVariable String applicationEnvironmentId) {
ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
if (!environment.getApplicationId().equals(applicationId)) {
throw new NotFoundException("Unable to find environment with id <" + applicationEnvironmentId + "> for application <" + applicationId + ">");
}
// Security check user must be authorized to deploy the environment (or be application manager)
AuthorizationUtil.checkAuthorizationForEnvironment(applicationService.getOrFail(applicationId), environment);
Deployment deployment = deploymentService.getActiveDeploymentOrFail(environment.getId());
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
return RestResponseBuilder.<TopologyDTO>builder().data(topologyDTOBuilder.initTopologyDTO(deploymentTopology, new TopologyDTO())).build();
}
use of alien4cloud.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.
the class BlockStorageEventHandler method processBlockStorageEvent.
private void processBlockStorageEvent(PaaSInstancePersistentResourceMonitorEvent persistentResourceEvent) {
if (persistentResourceEvent.getPersistentProperties() == null || (persistentResourceEvent.getPersistentProperties().isEmpty())) {
return;
}
DeploymentTopology runtimeTopo = alienMonitorDao.findById(DeploymentTopology.class, persistentResourceEvent.getDeploymentId());
Map<String, Object> persistentProperties = persistentResourceEvent.getPersistentProperties();
if (!persistentProperties.isEmpty() && valuesAreAllString(persistentProperties)) {
persistentProperties = getAggregatedVolumeIds(runtimeTopo, persistentResourceEvent.getNodeTemplateId(), persistentProperties);
if (persistentProperties.isEmpty()) {
return;
}
}
updateRuntimeTopology(runtimeTopo, persistentResourceEvent, persistentProperties);
updateApplicationTopology(persistentResourceEvent, persistentProperties);
}
use of alien4cloud.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.
the class DeploymentRuntimeStateService method getInstancesInformation.
/**
* Get the detailed status for each instance of each node template.
*
* @param deployment The deployment for witch to get the instance informations.
* @param callback callback on witch to send the map of node template's id to map of instance's id to instance information.
* @throws alien4cloud.paas.exception.OrchestratorDisabledException In case the cloud selected for the topology is disabled.
*/
public void getInstancesInformation(final Deployment deployment, IPaaSCallback<Map<String, Map<String, InstanceInformation>>> callback) throws OrchestratorDisabledException {
Map<String, Map<String, InstanceInformation>> instancesInformation = Maps.newHashMap();
if (deployment == null) {
callback.onSuccess(instancesInformation);
return;
}
DeploymentTopology runtimeTopology = alienMonitorDao.findById(DeploymentTopology.class, deployment.getId());
PaaSTopologyDeploymentContext deploymentContext = deploymentContextService.buildTopologyDeploymentContext(null, deployment, deploymentTopologyService.getLocations(runtimeTopology), runtimeTopology);
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
orchestratorPlugin.getInstancesInformation(deploymentContext, callback);
}
use of alien4cloud.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.
the class DeploymentRuntimeService method switchInstanceMaintenanceMode.
/**
* Switch an instance in a deployment to maintenance mode. If so the orchestrator should not perform self healing operations for this instance.
*
* @param applicationEnvironmentId The id of the application environment.
* @param nodeTemplateId The id of the node template on which to enable maintenance mode.
* @param instanceId The id of the instance.
* @param maintenanceModeOn true if we should enable the maintenance mode, false if we should disable it.
* @throws MaintenanceModeException In case the operation fails.
*/
public void switchInstanceMaintenanceMode(String applicationEnvironmentId, String nodeTemplateId, String instanceId, boolean maintenanceModeOn) throws MaintenanceModeException {
Deployment deployment = deploymentService.getActiveDeploymentOrFail(applicationEnvironmentId);
IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopologyFromEnvironment(deployment.getEnvironmentId());
PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deploymentTopology, null);
orchestratorPlugin.switchInstanceMaintenanceMode(deploymentContext, nodeTemplateId, instanceId, maintenanceModeOn);
}
Aggregations