use of alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method getLocationResourcesFromOrchestrator.
/*
* (non-Javadoc)
*
* @see
* alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResourcesFromOrchestrator(alien4cloud.model.orchestrators.locations.
* Location)
*/
@Override
public LocationResources getLocationResourcesFromOrchestrator(Location location) {
LocationResources locationResources = new LocationResources();
Orchestrator orchestrator = orchestratorService.getOrFail(location.getOrchestratorId());
IOrchestratorPlugin orchestratorInstance = orchestratorPluginService.getOrFail(orchestrator.getId());
ILocationConfiguratorPlugin configuratorPlugin = orchestratorInstance.getConfigurator(location.getInfrastructureType());
fillLocationResourceTypes(configuratorPlugin.getResourcesTypes(), locationResources, location.getDependencies());
fillPoliciesLocationResourceTypes(configuratorPlugin.getPoliciesTypes(), locationResources, location.getDependencies());
// add LocationResourceTemplate
List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
setLocationRessource(locationResourceTemplates, locationResources);
// add PolicyLocationResourceTemplate
locationResources.getPolicyTemplates().addAll(getPoliciesResourcesTemplates(location.getId()));
return locationResources;
}
use of alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method getLocationResources.
/*
* (non-Javadoc)
*
* @see alien4cloud.orchestrators.locations.services.ILocationResourceService#getLocationResources(alien4cloud.model.orchestrators.locations.Location)
*/
@Override
public LocationResources getLocationResources(Location location) {
Orchestrator orchestrator = orchestratorService.get(location.getOrchestratorId());
Optional<LocationResources> locationResourcesFromOrchestrator = Optional.empty();
if (orchestrator != null && orchestratorPluginService.get(orchestrator.getId()) != null) {
locationResourcesFromOrchestrator = Optional.ofNullable(getLocationResourcesFromOrchestrator(location));
}
// Also get resource templates from outside of the orchestrator definition - eg custom resources
List<LocationResourceTemplate> locationResourceTemplates = getResourcesTemplates(location.getId());
LocationResources locationResources = new LocationResources(getLocationResourceTypes(locationResourceTemplates));
// process policies types also
List<PolicyLocationResourceTemplate> policyLocationResourceTemplates = getPoliciesResourcesTemplates(location.getId());
locationResources.addFrom(getPoliciesLocationResourceTypes(policyLocationResourceTemplates));
/*
* If the orchestrator is present, take node types computed from the resources template
* as "Custom resources types". If not, consider this is an orchestrator-free location.
*/
locationResourcesFromOrchestrator.ifPresent(orchestratorResources -> {
locationResources.getCapabilityTypes().putAll(orchestratorResources.getCapabilityTypes());
locationResources.getConfigurationTypes().putAll(orchestratorResources.getConfigurationTypes());
locationResources.getNodeTypes().putAll(orchestratorResources.getNodeTypes());
locationResources.getProvidedTypes().addAll(orchestratorResources.getNodeTypes().keySet());
locationResources.getAllNodeTypes().putAll(orchestratorResources.getAllNodeTypes());
locationResources.getOnDemandTypes().putAll(orchestratorResources.getOnDemandTypes());
locationResources.getPolicyTypes().putAll(orchestratorResources.getPolicyTypes());
});
setLocationRessource(locationResourceTemplates, locationResources);
locationResources.getPolicyTemplates().addAll(policyLocationResourceTemplates);
return locationResources;
}
use of alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method addPolicyLocationResourceTemplate.
private PolicyLocationResourceTemplate addPolicyLocationResourceTemplate(Location location, String resourceName, String resourceTypeName) {
PolicyLocationResourceTemplate policyLocationResourceTemplate = new PolicyLocationResourceTemplate();
PolicyType resourceType = csarRepoSearchService.getRequiredElementInDependencies(PolicyType.class, resourceTypeName, location.getDependencies());
PolicyTemplate policyTemplate = TemplateBuilder.buildPolicyTemplate(resourceType);
fillAndSaveLocationResourceTemplate(location, resourceName, policyLocationResourceTemplate, resourceType, policyTemplate);
return policyLocationResourceTemplate;
}
use of alien4cloud.model.orchestrators.locations.PolicyLocationResourceTemplate in project alien4cloud by alien4cloud.
the class LocationResourceService method duplicatePolicyTemplate.
@Override
public LocationResourceTemplateWithDependencies duplicatePolicyTemplate(String resourceId) {
PolicyLocationResourceTemplate policyLocationResourceTemplate = getOrFail(resourceId);
policyLocationResourceTemplate.setId(UUID.randomUUID().toString());
policyLocationResourceTemplate.setName(policyLocationResourceTemplate.getName() + "_" + "copy");
Location location = locationService.getOrFail(policyLocationResourceTemplate.getLocationId());
PolicyType resourceType = csarRepoSearchService.getRequiredElementInDependencies(PolicyType.class, policyLocationResourceTemplate.getTemplate().getType(), location.getDependencies());
publishCreatedEventAndSaveResource(location, policyLocationResourceTemplate, resourceType);
return new LocationResourceTemplateWithDependencies(policyLocationResourceTemplate, Sets.newHashSet(location.getDependencies()));
}
Aggregations