Search in sources :

Example 81 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationStepDefinitions method the_application_can_be_found_in_ALIEN.

@Then("^the application can be found in ALIEN$")
public Application the_application_can_be_found_in_ALIEN() throws Throwable {
    String appId = CURRENT_APPLICATION.getId();
    RestResponse<Application> response = JsonUtil.read(getRestClientInstance().get("/rest/v1/applications/" + appId), Application.class);
    assertNotNull(response.getData());
    return response.getData();
}
Also used : TestUtils.nullAsString(alien4cloud.it.utils.TestUtils.nullAsString) Application(alien4cloud.model.application.Application) Then(cucumber.api.java.en.Then)

Example 82 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method I_get_the_deployment_topology_for_the_current_application.

@When("^I get the deployment topology for the current application on the environment \"(.*?)\"$")
public void I_get_the_deployment_topology_for_the_current_application(String environment) throws Throwable {
    Application application = Context.getInstance().getApplication();
    String environmentId = Context.getInstance().getApplicationEnvironmentId(application.getName(), environment);
    String restUrl = String.format("/rest/v1/applications/%s/environments/%s/deployment-topology/", application.getId(), environmentId);
    String response = Context.getRestClientInstance().get(restUrl);
    Context.getInstance().registerRestResponse(response);
}
Also used : Application(alien4cloud.model.application.Application) When(cucumber.api.java.en.When)

Example 83 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class Context method takeApplication.

public Application takeApplication() {
    Application app = applicationLocal;
    applicationLocal = null;
    return app;
}
Also used : Application(alien4cloud.model.application.Application)

Example 84 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method deploy.

/**
 * Trigger deployment of the application on the current configured PaaS.
 *
 * @param deployApplicationRequest application details for deployment (applicationId + deploymentProperties)
 * @return An empty rest response.
 */
@ApiOperation(value = "Deploys the application on the configured Cloud.", notes = "Application role required [ APPLICATION_MANAGER | APPLICATION_DEVOPS ] and Application environment role required [ DEPLOYMENT_MANAGER ]")
@RequestMapping(value = "/deployment", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Audit(bodyHiddenFields = { "secretProviderCredentials" })
public RestResponse<?> deploy(@Valid @RequestBody DeployApplicationRequest deployApplicationRequest) {
    String applicationId = deployApplicationRequest.getApplicationId();
    String environmentId = deployApplicationRequest.getApplicationEnvironmentId();
    Application application = applicationService.checkAndGetApplication(applicationId);
    ApplicationEnvironment environment = applicationEnvironmentService.getEnvironmentByIdOrDefault(applicationId, environmentId);
    if (!environment.getApplicationId().equals(applicationId)) {
        throw new NotFoundException("Unable to find environment with id <" + environmentId + "> for application <" + applicationId + ">");
    }
    // Security check user must be authorized to deploy the environment (or be application manager)
    AuthorizationUtil.checkAuthorizationForEnvironment(application, environment);
    // ensure deployment status is sync with underlying orchestrator
    applicationEnvironmentService.getStatus(environment);
    // check that the environment is not already deployed
    boolean isEnvironmentDeployed = applicationEnvironmentService.isDeployed(environment.getId());
    if (isEnvironmentDeployed) {
        throw new AlreadyExistException("Environment with id <" + environmentId + "> for application <" + applicationId + "> is already deployed");
    }
    // prepare the deployment
    ApplicationTopologyVersion topologyVersion = applicationVersionService.getOrFail(Csar.createId(environment.getApplicationId(), environment.getVersion()), environment.getTopologyVersion());
    Topology topology = topologyServiceCore.getOrFail(topologyVersion.getArchiveId());
    return toscaContextualAspect.execInToscaContext(() -> doDeploy(deployApplicationRequest, application, environment, topology), false, topology);
}
Also used : NotFoundException(alien4cloud.exception.NotFoundException) DeploymentTopology(alien4cloud.model.deployment.DeploymentTopology) Topology(org.alien4cloud.tosca.model.templates.Topology) AlreadyExistException(alien4cloud.exception.AlreadyExistException) Application(alien4cloud.model.application.Application) ApplicationEnvironment(alien4cloud.model.application.ApplicationEnvironment) ApplicationTopologyVersion(alien4cloud.model.application.ApplicationTopologyVersion) Audit(alien4cloud.audit.annotation.Audit) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 85 with Application

use of alien4cloud.model.application.Application in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method getApplicationsEnvironments.

@ApiOperation(value = "Get all environments including their current deployment status for a list of applications.", notes = "Return the environements for all given applications. Note that only environments the user is authorized to see are returned.")
@RequestMapping(value = "/environments", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@PreAuthorize("isAuthenticated()")
@Deprecated
public RestResponse<Map<String, ApplicationEnvironmentDTO[]>> getApplicationsEnvironments(@RequestBody List<String> applicationIds) {
    Map<String, ApplicationEnvironmentDTO[]> envsByApplicationId = Maps.newHashMap();
    for (String applicationId : applicationIds) {
        Application application = applicationService.checkAndGetApplication(applicationId);
        // get all environments status for the current application
        ApplicationEnvironment[] environments = applicationEnvironmentService.getByApplicationId(application.getId());
        List<ApplicationEnvironmentDTO> userEnvironmentList = new ArrayList<>(environments.length);
        for (ApplicationEnvironment env : environments) {
            if (AuthorizationUtil.hasAuthorizationForEnvironment(application, env, ApplicationEnvironmentRole.values())) {
                userEnvironmentList.add(dtoBuilder.getApplicationEnvironmentDTO(env));
            }
        }
        envsByApplicationId.put(applicationId, userEnvironmentList.toArray(new ApplicationEnvironmentDTO[userEnvironmentList.size()]));
    }
    return RestResponseBuilder.<Map<String, ApplicationEnvironmentDTO[]>>builder().data(envsByApplicationId).build();
}
Also used : ApplicationEnvironmentDTO(alien4cloud.rest.application.model.ApplicationEnvironmentDTO) ArrayList(java.util.ArrayList) 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

Application (alien4cloud.model.application.Application)103 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)45 ApiOperation (io.swagger.annotations.ApiOperation)43 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)39 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)38 Audit (alien4cloud.audit.annotation.Audit)28 List (java.util.List)14 Topology (org.alien4cloud.tosca.model.templates.Topology)14 Set (java.util.Set)12 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)11 RestResponse (alien4cloud.rest.model.RestResponse)11 Collectors (java.util.stream.Collectors)11 Map (java.util.Map)10 ApplicationEnvironmentService (alien4cloud.application.ApplicationEnvironmentService)9 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)9 Arrays (java.util.Arrays)9 When (cucumber.api.java.en.When)8 Deployment (alien4cloud.model.deployment.Deployment)7 RestResponseBuilder (alien4cloud.rest.model.RestResponseBuilder)7 ApplicationEnvironmentAuthorizationDTO (alien4cloud.rest.orchestrator.model.ApplicationEnvironmentAuthorizationDTO)7