Search in sources :

Example 71 with Application

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

the class ApplicationsDeploymentStepDefinitions method I_undeploy_all_applications.

@Given("^I undeploy all environments for applications$")
public void I_undeploy_all_applications() throws Throwable {
    assertNotNull(ApplicationStepDefinitions.CURRENT_APPLICATIONS);
    for (String applicationName : ApplicationStepDefinitions.CURRENT_APPLICATIONS.keySet()) {
        Application application = ApplicationStepDefinitions.CURRENT_APPLICATIONS.get(applicationName);
        log.info("APPLICATION : {} - {}", application.getName(), application.getId());
        // for each application undeploy all environment
        Map<String, String> environments = Context.getInstance().getAllEnvironmentForApplication(applicationName);
        for (Map.Entry<String, String> env : environments.entrySet()) {
            log.info(env.getKey() + "/" + env.getValue());
            log.info("ENVIRONMENT to undeploy : {} - {}", env.getKey(), env.getValue());
            Context.getRestClientInstance().delete("/rest/v1/applications/" + application.getId() + "/environments/" + env.getValue() + "/deployment");
            assertStatus(application.getName(), DeploymentStatus.UNDEPLOYED, Sets.newHashSet(DeploymentStatus.UNDEPLOYMENT_IN_PROGRESS), 10 * 60L * 1000L, null);
        }
    }
}
Also used : Application(alien4cloud.model.application.Application) Map(java.util.Map) Given(cucumber.api.java.en.Given)

Example 72 with Application

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

the class ApplicationsDeploymentStepDefinitions method I_deploy_all_applications_on_the_location.

@When("^I deploy all applications on the location \"([^\"]*)\"/\"([^\"]*)\"$")
public void I_deploy_all_applications_on_the_location(String orchestratorName, String locationName) throws Throwable {
    assertNotNull(ApplicationStepDefinitions.CURRENT_APPLICATIONS);
    for (String key : ApplicationStepDefinitions.CURRENT_APPLICATIONS.keySet()) {
        Application app = ApplicationStepDefinitions.CURRENT_APPLICATIONS.get(key);
        Context.getInstance().registerApplication(app);
        deploymentTopoSteps.I_Set_a_unique_location_policy_to_for_all_nodes(orchestratorName, locationName);
        String appName = app.getName();
        Map<String, String> environments = Context.getInstance().getAllEnvironmentForApplication(appName);
        DeployApplicationRequest deployApplicationRequest = null;
        for (Map.Entry<String, String> env : environments.entrySet()) {
            String envName = env.getKey();
            deployApplicationRequest = getDeploymentAppRequest(appName, envName);
            String response = deploy(deployApplicationRequest);
            Context.getInstance().registerRestResponse(response);
        }
        commonSteps.I_should_receive_a_RestResponse_with_no_error();
    }
}
Also used : DeployApplicationRequest(alien4cloud.rest.application.model.DeployApplicationRequest) Application(alien4cloud.model.application.Application) Map(java.util.Map) When(cucumber.api.java.en.When)

Example 73 with Application

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

the class ApplicationsDeploymentStepDefinitions method getDeploymentAppRequest.

public static DeployApplicationRequest getDeploymentAppRequest(String applicationName, String environmentName) throws IOException {
    DeployApplicationRequest deployApplicationRequest = new DeployApplicationRequest();
    Application application = ApplicationStepDefinitions.CURRENT_APPLICATION;
    // set application id and environment id for the request
    String applicationId = (applicationName == null) ? application.getId() : Context.getInstance().getApplicationId(applicationName);
    deployApplicationRequest.setApplicationId(applicationId);
    String environmentId = (environmentName == null) ? Context.getInstance().getDefaultApplicationEnvironmentId(applicationName) : Context.getInstance().getApplicationEnvironmentId(applicationName, environmentName);
    deployApplicationRequest.setApplicationEnvironmentId(environmentId);
    return deployApplicationRequest;
}
Also used : DeployApplicationRequest(alien4cloud.rest.application.model.DeployApplicationRequest) Application(alien4cloud.model.application.Application)

Example 74 with Application

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

the class DeploymentTopologyStepDefinitions method updateProperty.

private void updateProperty(String propertyName, Object propertyValue, String nodeName, String endpoint) throws IOException {
    Context context = Context.getInstance();
    Application application = context.getApplication();
    String envId = context.getDefaultApplicationEnvironmentId(application.getName());
    UpdatePropertyRequest request = new UpdatePropertyRequest(propertyName, propertyValue);
    String restUrl = String.format(endpoint, application.getId(), envId, nodeName);
    String response = Context.getRestClientInstance().postJSon(restUrl, JsonUtil.toString(request));
    context.registerRestResponse(response);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) UpdatePropertyRequest(alien4cloud.rest.topology.UpdatePropertyRequest) Application(alien4cloud.model.application.Application)

Example 75 with Application

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

the class DeploymentTopologyStepDefinitions method doSubstitution.

public void doSubstitution(String templateName, String resourceId, String restUrlFormat) throws IOException {
    Context context = Context.getInstance();
    Application application = context.getApplication();
    String envId = context.getDefaultApplicationEnvironmentId(application.getName());
    String restUrl = String.format(restUrlFormat, application.getId(), envId, templateName);
    NameValuePair resourceParam = new BasicNameValuePair("locationResourceTemplateId", resourceId);
    String response = Context.getRestClientInstance().postUrlEncoded(restUrl, Lists.newArrayList(resourceParam));
    context.registerRestResponse(response);
}
Also used : EvaluationContext(org.springframework.expression.EvaluationContext) Context(alien4cloud.it.Context) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) NameValuePair(org.apache.http.NameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) BasicNameValuePair(org.apache.http.message.BasicNameValuePair) Application(alien4cloud.model.application.Application)

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