Search in sources :

Example 26 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class NodeMatchingStepDefinitions method checkSubstitutionCounts.

@Then("^Available substitution should contains (\\d+) proposal including (\\d+) service$")
public void checkSubstitutionCounts(int proposals, int services) throws Throwable {
    RestResponse<DeploymentTopologyDTO> restResponse = JsonUtil.read(Context.getInstance().getRestResponse(), DeploymentTopologyDTO.class);
    Assert.assertEquals(proposals, restResponse.getData().getAvailableSubstitutions().getSubstitutionsTemplates().size());
    int actualServices = 0;
    for (LocationResourceTemplate resourceTemplate : restResponse.getData().getAvailableSubstitutions().getSubstitutionsTemplates().values()) {
        if (resourceTemplate.isService()) {
            actualServices++;
        }
    }
    Assert.assertEquals(services, actualServices);
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) Then(cucumber.api.java.en.Then)

Example 27 with DeploymentTopologyDTO

use of alien4cloud.deployment.DeploymentTopologyDTO in project alien4cloud by alien4cloud.

the class ApplicationDeploymentController method doDeploy.

private RestResponse<?> doDeploy(DeployApplicationRequest deployApplicationRequest, Application application, ApplicationEnvironment environment, Topology topology) {
    DeploymentTopologyDTO deploymentTopologyDTO = deploymentTopologyDTOBuilder.prepareDeployment(topology, application, environment);
    TopologyValidationResult validation = deploymentTopologyDTO.getValidation();
    // if not valid, then return validation errors
    if (!validation.isValid()) {
        return RestResponseBuilder.<TopologyValidationResult>builder().error(new RestError(RestErrorCode.INVALID_DEPLOYMENT_TOPOLOGY.getCode(), "The deployment topology for the application <" + application.getName() + "> on the environment <" + environment.getName() + "> is not valid.")).data(validation).build();
    }
    User deployer = AuthorizationUtil.getCurrentUser();
    // commit and push the deployment configuration data
    GitLocation location = gitLocationDao.findDeploymentSetupLocation(application.getId(), environment.getId());
    localGitManager.commitAndPush(location, deployer.getUsername(), deployer.getEmail(), "Deployment " + DateTime.now(DateTimeZone.UTC));
    // the request contains secret provider credentials?
    SecretProviderCredentials secretProviderCredentials = null;
    if (deployApplicationRequest.getSecretProviderCredentials() != null && deployApplicationRequest.getSecretProviderPluginName() != null) {
        secretProviderCredentials = new SecretProviderCredentials();
        secretProviderCredentials.setCredentials(deployApplicationRequest.getSecretProviderCredentials());
        secretProviderCredentials.setPluginName(deployApplicationRequest.getSecretProviderPluginName());
    }
    // process with the deployment
    deployService.deploy(deployer, secretProviderCredentials, deploymentTopologyDTO.getTopology(), application);
    return RestResponseBuilder.<Void>builder().build();
}
Also used : TopologyValidationResult(alien4cloud.topology.TopologyValidationResult) SecretProviderCredentials(alien4cloud.deployment.model.SecretProviderCredentials) User(alien4cloud.security.model.User) RestError(alien4cloud.rest.model.RestError) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) GitLocation(org.alien4cloud.git.model.GitLocation)

Aggregations

DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)27 Then (cucumber.api.java.en.Then)13 Application (alien4cloud.model.application.Application)8 ApiOperation (io.swagger.annotations.ApiOperation)8 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 ApplicationEnvironment (alien4cloud.model.application.ApplicationEnvironment)7 ApplicationTopologyVersion (alien4cloud.model.application.ApplicationTopologyVersion)7 DeploymentTopology (alien4cloud.model.deployment.DeploymentTopology)7 Topology (org.alien4cloud.tosca.model.templates.Topology)7 Audit (alien4cloud.audit.annotation.Audit)6 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)5 ConstraintFunctionalException (org.alien4cloud.tosca.exceptions.ConstraintFunctionalException)4 ConstraintTechnicalException (org.alien4cloud.tosca.exceptions.ConstraintTechnicalException)4 FunctionPropertyValue (org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)3 Context (alien4cloud.it.Context)2 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)2 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)2 RestError (alien4cloud.rest.model.RestError)2 RestResponse (alien4cloud.rest.model.RestResponse)2