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);
}
}
}
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();
}
}
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;
}
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);
}
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);
}
Aggregations