use of alien4cloud.orchestrators.plugin.ILocationResourceAccessor in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method getResources.
@Test
public void getResources() {
ILocationResourceAccessor accessor = locationResourceService.accessor(LOCATION_ID);
List<LocationResourceTemplate> resources = accessor.getResources();
Assert.assertEquals(LOCATION_CONFIGURED_ELEMENTS, resources.size());
}
use of alien4cloud.orchestrators.plugin.ILocationResourceAccessor in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method getResourcesOfTypeForUnconfiguredLocationShouldReturnEmptyList.
@Test
public void getResourcesOfTypeForUnconfiguredLocationShouldReturnEmptyList() {
ILocationResourceAccessor accessor = locationResourceService.accessor(UNCONFIGURED_LOCATION_ID);
List<LocationResourceTemplate> resources = accessor.getResources(CONFIGURED_TYPE);
Assert.assertEquals(0, resources.size());
}
use of alien4cloud.orchestrators.plugin.ILocationResourceAccessor in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method getResourcesForUnconfiguredLocationShouldReturnEmptyList.
@Test
public void getResourcesForUnconfiguredLocationShouldReturnEmptyList() {
ILocationResourceAccessor accessor = locationResourceService.accessor(UNCONFIGURED_LOCATION_ID);
List<LocationResourceTemplate> resources = accessor.getResources();
Assert.assertEquals(0, resources.size());
}
use of alien4cloud.orchestrators.plugin.ILocationResourceAccessor in project alien4cloud by alien4cloud.
the class LocationResourceServiceTest method getResourcesOfType.
@Test
public void getResourcesOfType() {
ILocationResourceAccessor accessor = locationResourceService.accessor(LOCATION_ID);
List<LocationResourceTemplate> resources = accessor.getResources(CONFIGURED_TYPE);
Assert.assertEquals(TYPE_CONFIGURED_ELEMENTS, resources.size());
}
use of alien4cloud.orchestrators.plugin.ILocationResourceAccessor in project alien4cloud by alien4cloud.
the class LocationService method autoConfigure.
/**
* This method calls the orchestrator plugin to try to auto-configure the
*
* @param orchestrator The orchestrator for which to auto-configure a location.
* @param location The location to auto-configure
* @return the List of {@link LocationResourceTemplate} generated from the location auto-configuration call, null is a valid answer.
*/
private List<LocationResourceTemplate> autoConfigure(Orchestrator orchestrator, Location location) throws UnsupportedOperationException {
// get the orchestrator plugin instance
IOrchestratorPlugin orchestratorInstance = (IOrchestratorPlugin) orchestratorPluginService.getOrFail(orchestrator.getId());
ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
IOrchestratorPluginFactory orchestratorFactory = orchestratorService.getPluginFactory(orchestrator);
ILocationResourceAccessor accessor = locationResourceService.accessor(location.getId());
// let's try to auto-configure the location
List<LocationResourceTemplate> templates = configuratorPlugin.instances(accessor);
if (templates != null) {
// save the instances
for (LocationResourceTemplate template : templates) {
// initialize the instances from data.
template.setId(UUID.randomUUID().toString());
template.setLocationId(location.getId());
template.setGenerated(true);
template.setEnabled(true);
NodeType nodeType = csarRepoSearchService.getRequiredElementInDependencies(NodeType.class, template.getTemplate().getType(), location.getDependencies());
nodeType.getDerivedFrom().add(0, template.getTemplate().getType());
template.setTypes(nodeType.getDerivedFrom());
LocationTemplateCreated event = new LocationTemplateCreated(this);
event.setTemplate(template);
event.setLocation(location);
event.setToscaType(nodeType);
applicationContext.publishEvent(event);
}
alienDAO.save(templates.toArray(new LocationResourceTemplate[templates.size()]));
alienDAO.save(location);
}
return templates;
}
Aggregations