Search in sources :

Example 41 with Deployment

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

the class ApplicationDeploymentController method getSecretProviderConfigurationsForCurrentDeployment.

@ApiOperation(value = "Get current secret provider configuration for the given application on the given cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/{applicationId:.+}/environments/{applicationEnvironmentId}/current-secret-provider-configurations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<List<SecretCredentialInfo>> getSecretProviderConfigurationsForCurrentDeployment(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) {
    Application application = applicationService.checkAndGetApplication(applicationId);
    // get the topology from the version and the cloud from the environment
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(application.getId(), applicationEnvironmentId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.APPLICATION_USER);
    Deployment deployment = deploymentService.getActiveDeployment(environment.getId());
    List<SecretCredentialInfo> secretProviderConfigurations = Lists.newArrayList();
    for (int i = 0; i < deployment.getLocationIds().length; i++) {
        Location location = locationService.getOrFail(deployment.getLocationIds()[i]);
        if (location.getSecretProviderConfiguration() != null) {
            secretProviderConfigurations.add(secretProviderService.getSecretCredentialInfo(location.getSecretProviderConfiguration().getPluginName(), location.getSecretProviderConfiguration().getConfiguration()));
        }
    }
    return RestResponseBuilder.<List<SecretCredentialInfo>>builder().data(secretProviderConfigurations).build();
}
Also used : Deployment(alien4cloud.model.deployment.Deployment) SecretCredentialInfo(org.alien4cloud.alm.deployment.configuration.model.SecretCredentialInfo) List(java.util.List) ArrayList(java.util.ArrayList) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) GitLocation(org.alien4cloud.git.model.GitLocation) Location(alien4cloud.model.orchestrators.locations.Location) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with Deployment

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

the class ApplicationDeploymentController method getActiveDeployment.

/**
 * Get only the active deployment for the given application on the given cloud
 *
 * @param applicationId id of the topology
 * @return the active deployment
 */
@ApiOperation(value = "Get active deployment for the given application on the given cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/{applicationId:.+}/environments/{applicationEnvironmentId}/active-deployment", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
public RestResponse<Deployment> getActiveDeployment(@PathVariable String applicationId, @PathVariable String applicationEnvironmentId) {
    Application application = applicationService.checkAndGetApplication(applicationId);
    // get the topology from the version and the cloud from the environment
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(application.getId(), applicationEnvironmentId);
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment, ApplicationEnvironmentRole.APPLICATION_USER);
    Deployment deployment = deploymentService.getActiveDeployment(environment.getId());
    return RestResponseBuilder.<Deployment>builder().data(deployment).build();
}
Also used : Deployment(alien4cloud.model.deployment.Deployment) Application(alien4cloud.model.application.Application) 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 43 with Deployment

use of alien4cloud.model.deployment.Deployment 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

Deployment (alien4cloud.model.deployment.Deployment)43 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)13 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)11 ApiOperation (io.swagger.annotations.ApiOperation)9 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 NotFoundException (alien4cloud.exception.NotFoundException)6 Application (alien4cloud.model.application.Application)6 Location (alien4cloud.model.orchestrators.locations.Location)6 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)5 ApplicationVersion (alien4cloud.model.application.ApplicationVersion)3 Usage (alien4cloud.model.common.Usage)3 PaaSDeploymentContext (alien4cloud.paas.model.PaaSDeploymentContext)3 Date (java.util.Date)3 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)2 SecretProviderConfigurationAndCredentials (alien4cloud.deployment.model.SecretProviderConfigurationAndCredentials)2 AlreadyExistException (alien4cloud.exception.AlreadyExistException)2 ServiceResource (alien4cloud.model.service.ServiceResource)2 OrchestratorDisabledException (alien4cloud.paas.exception.OrchestratorDisabledException)2 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)2