Search in sources :

Example 6 with DeploymentTopology

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

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();
}
Also used : TopologyDTO(alien4cloud.topology.TopologyDTO) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) NotFoundException(alien4cloud.exception.NotFoundException) Deployment(alien4cloud.model.deployment.Deployment) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with DeploymentTopology

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);
}
Also used : DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology)

Example 9 with DeploymentTopology

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);
}
Also used : DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Map(java.util.Map) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Example 10 with DeploymentTopology

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);
}
Also used : PaaSDeploymentContext(alien4cloud.paas.model.PaaSDeploymentContext) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Deployment(alien4cloud.model.deployment.Deployment) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin)

Aggregations

DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)22 Deployment (alien4cloud.model.deployment.Deployment)11 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)6 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)5 Location (alien4cloud.model.orchestrators.locations.Location)5 PaaSDeploymentContext (alien4cloud.paas.model.PaaSDeploymentContext)4 SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)3 ApiOperation (io.swagger.annotations.ApiOperation)3 Map (java.util.Map)3 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 NotFoundException (alien4cloud.exception.NotFoundException)2 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)2 PaaSNodeTemplate (alien4cloud.paas.model.PaaSNodeTemplate)2 PaaSTopology (alien4cloud.paas.model.PaaSTopology)2 PaaSTopologyDeploymentContext (alien4cloud.paas.model.PaaSTopologyDeploymentContext)2 TopologyDTO (alien4cloud.topology.TopologyDTO)2 ParsingException (alien4cloud.tosca.parser.ParsingException)2 IOException (java.io.IOException)2 ZipException (java.util.zip.ZipException)2