Search in sources :

Example 26 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate in project alien4cloud by alien4cloud.

the class OrchestrationLocationResourceSteps method I_autogenerate_the_on_demand_resources_for_the_location_.

@When("^I autogenerate the on-demand resources for the location \"([^\"]*)\"/\"([^\"]*)\"$")
public void I_autogenerate_the_on_demand_resources_for_the_location_(String orchestratorName, String locationName) throws Throwable {
    String orchestratorId = Context.getInstance().getOrchestratorId(orchestratorName);
    String locationId = Context.getInstance().getLocationId(orchestratorId, locationName);
    String restUrl = String.format(LOCATION_RESOURCES_BASE_ENDPOINT + "/auto-configure", orchestratorId, locationId);
    String resp = Context.getRestClientInstance().get(restUrl);
    Context.getInstance().registerRestResponse(resp);
    RestResponse<List> response = JsonUtil.read(resp, List.class, Context.getJsonMapper());
    if (response.getData() != null) {
        List<LocationResourceTemplate> resources = JsonUtil.toList(JsonUtil.toString(response.getData()), LocationResourceTemplate.class, Context.getJsonMapper());
        for (LocationResourceTemplate locationResourceTemplate : resources) {
            Context.getInstance().registerOrchestratorLocationResource(orchestratorId, locationId, locationResourceTemplate.getId(), locationResourceTemplate.getName());
        }
    }
}
Also used : LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) List(java.util.List) When(cucumber.api.java.en.When)

Example 27 with LocationResourceTemplate

use of alien4cloud.model.orchestrators.locations.LocationResourceTemplate 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)

Aggregations

LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)27 NodeType (org.alien4cloud.tosca.model.types.NodeType)14 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)11 Test (org.junit.Test)11 MatchingConfiguration (alien4cloud.model.deployment.matching.MatchingConfiguration)6 PolicyLocationResourceTemplate (alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate)6 ILocationResourceAccessor (alien4cloud.orchestrators.plugin.ILocationResourceAccessor)6 HashMap (java.util.HashMap)6 AbstractLocationResourceTemplate (alien4cloud.model.orchestrators.locations.AbstractLocationResourceTemplate)5 Location (alien4cloud.model.orchestrators.locations.Location)4 Orchestrator (alien4cloud.model.orchestrators.Orchestrator)3 LocationResources (alien4cloud.model.orchestrators.locations.LocationResources)3 CSARDependency (org.alien4cloud.tosca.model.CSARDependency)3 ServiceResource (alien4cloud.model.service.ServiceResource)2 ILocationConfiguratorPlugin (alien4cloud.orchestrators.plugin.ILocationConfiguratorPlugin)2 IOrchestratorPlugin (alien4cloud.orchestrators.plugin.IOrchestratorPlugin)2 List (java.util.List)2 CapabilityDefinition (org.alien4cloud.tosca.model.definitions.CapabilityDefinition)2 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)2 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)1