Search in sources :

Example 21 with DeploymentTopology

use of alien4cloud.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.

the class UndeployService method undeploy.

private void undeploy(SecretProviderConfigurationAndCredentials secretProviderConfigurationAndCredentials, final Deployment deployment) {
    deploymentLockService.doWithDeploymentWriteLock(deployment.getOrchestratorDeploymentId(), () -> {
        log.info("Un-deploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
        IOrchestratorPlugin orchestratorPlugin = orchestratorPluginService.getOrFail(deployment.getOrchestratorId());
        DeploymentTopology deployedTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
        Map<String, String> locationIds = TopologyLocationUtils.getLocationIds(deployedTopology);
        Map<String, Location> locations = deploymentTopologyService.getLocations(locationIds);
        SecretProviderConfigurationAndCredentials authResponse = null;
        if (secretProviderService.isSecretProvided(secretProviderConfigurationAndCredentials)) {
            authResponse = secretProviderService.generateToken(locations, secretProviderConfigurationAndCredentials.getSecretProviderConfiguration().getPluginName(), secretProviderConfigurationAndCredentials.getCredentials());
        }
        PaaSDeploymentContext deploymentContext = new PaaSDeploymentContext(deployment, deployedTopology, authResponse);
        orchestratorPlugin.undeploy(deploymentContext, new IPaaSCallback<ResponseEntity>() {

            @Override
            public void onSuccess(ResponseEntity data) {
                deploymentService.markUndeployed(deployment);
                log.info("Un-deployed deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
            }

            @Override
            public void onFailure(Throwable throwable) {
                log.warn("Fail while Undeploying deployment [{}] on orchestrator [{}]", deployment.getId(), deployment.getOrchestratorId());
            }
        });
        return null;
    });
}
Also used : PaaSDeploymentContext(alien4cloud.paas.model.PaaSDeploymentContext) ResponseEntity(org.springframework.http.ResponseEntity) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) SecretProviderConfigurationAndCredentials(alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials) IOrchestratorPlugin(alien4cloud.orchestrators.plugin.IOrchestratorPlugin) Location(alien4cloud.model.orchestrators.locations.Location)

Example 22 with DeploymentTopology

use of alien4cloud.model.deployment.DeploymentTopology in project alien4cloud by alien4cloud.

the class RuntimeController method getNonNativesNodes.

@ApiOperation(value = "Get non-natives node template of a topology.", notes = "Returns An map of non-natives {@link NodeTemplate}. Application role required [ APPLICATION_MANAGER | DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/{applicationId:.+?}/environment/{applicationEnvironmentId:.+?}/nonNatives", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<Map<String, NodeTemplate>> getNonNativesNodes(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) {
    Application application = applicationService.getOrFail(applicationId);
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, applicationEnvironmentId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
    Deployment deployment = deploymentService.getActiveDeploymentOrFail(environment.getId());
    DeploymentTopology deploymentTopology = deploymentRuntimeStateService.getRuntimeTopology(deployment.getId());
    Map<String, NodeTemplate> nonNativesNode = topologyTreeBuilderService.getNonNativesNodes(deploymentTopology);
    return RestResponseBuilder.<Map<String, NodeTemplate>>builder().data(nonNativesNode).build();
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Deployment(alien4cloud.model.deployment.Deployment) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) Map(java.util.Map) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

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