use of alien4cloud.paas.model.PaaSRelationshipTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processOperationsOutputs.
/**
* For every templates (nodes and relationship), check the attributes and interfaces operations input parameters for usage of the get_operation_output
* function.
* if found, register the referenced output on the related operation
*
* @param paaSNodeTemplates
*/
private void processOperationsOutputs(final Map<String, PaaSNodeTemplate> paaSNodeTemplates) {
// TODO: try to cache already processed nodes
for (PaaSNodeTemplate paaSNodeTemplate : paaSNodeTemplates.values()) {
processAttributesForOperationOutputs(paaSNodeTemplate, paaSNodeTemplates);
processOperationsInputsForOperationOutputs(paaSNodeTemplate, paaSNodeTemplates);
// do the same for the relationships
for (PaaSRelationshipTemplate paaSRelationshipTemplate : paaSNodeTemplate.getRelationshipTemplates()) {
processAttributesForOperationOutputs(paaSRelationshipTemplate, paaSNodeTemplates);
processOperationsInputsForOperationOutputs(paaSRelationshipTemplate, paaSNodeTemplates);
}
}
}
use of alien4cloud.paas.model.PaaSRelationshipTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method processNetwork.
private void processNetwork(PaaSNodeTemplate paaSNodeTemplate, Map<String, PaaSNodeTemplate> nodeTemplates) {
List<PaaSRelationshipTemplate> networkRelationships = getPaaSRelationshipsTemplateFromType(paaSNodeTemplate, NormativeRelationshipConstants.NETWORK);
List<PaaSNodeTemplate> networks = Lists.newArrayList();
if (networkRelationships != null && !networkRelationships.isEmpty()) {
for (PaaSRelationshipTemplate networkRelationship : networkRelationships) {
String target = networkRelationship.getTemplate().getTarget();
PaaSNodeTemplate network = nodeTemplates.get(target);
networks.add(network);
network.setParent(paaSNodeTemplate);
}
}
paaSNodeTemplate.setNetworkNodes(networks);
}
use of alien4cloud.paas.model.PaaSRelationshipTemplate in project alien4cloud by alien4cloud.
the class TopologyTreeBuilderService method buildPaaSNodeTemplates.
/**
* Fetch information from the repository to complete the topology node template informations with additional data such as artifacts paths etc.
*
* @param topology The topology for which to build PaaSNodeTemplate map.
* @return A map of PaaSNodeTemplate that match the one of the NodeTempaltes in the given topology (and filled with artifact paths etc.).
*/
public Map<String, PaaSNodeTemplate> buildPaaSNodeTemplates(Topology topology) {
Map<String, PaaSNodeTemplate> nodeTemplates = Maps.newHashMap();
// Fill in PaaSNodeTemplate by fetching node types and CSAR path from the repositories.
if (topology.getNodeTemplates() != null) {
for (Entry<String, NodeTemplate> templateEntry : topology.getNodeTemplates().entrySet()) {
NodeTemplate template = templateEntry.getValue();
PaaSNodeTemplate paaSNodeTemplate = new PaaSNodeTemplate(templateEntry.getKey(), template);
fillType(topology, template, paaSNodeTemplate, NodeType.class);
mergeInterfaces(paaSNodeTemplate, template);
if (template.getRelationships() != null) {
for (Map.Entry<String, RelationshipTemplate> relationshipEntry : template.getRelationships().entrySet()) {
RelationshipTemplate relationshipTemplate = relationshipEntry.getValue();
PaaSRelationshipTemplate paaSRelationshipTemplate = new PaaSRelationshipTemplate(relationshipEntry.getKey(), relationshipTemplate, paaSNodeTemplate.getId());
fillType(topology, relationshipTemplate, paaSRelationshipTemplate, RelationshipType.class);
mergeInterfaces(paaSRelationshipTemplate, relationshipTemplate);
paaSNodeTemplate.getRelationshipTemplates().add(paaSRelationshipTemplate);
}
}
Capability scalableCapability = TopologyUtils.getScalableCapability(topology, templateEntry.getKey(), false);
if (scalableCapability != null) {
ScalingPolicy scalingPolicy = TopologyUtils.getScalingPolicy(scalableCapability);
// A node with a scaling policy 1, 1, 1 is a simple node and so do not set scaling policy
if (!ScalingPolicy.NOT_SCALABLE_POLICY.equals(scalingPolicy)) {
paaSNodeTemplate.setScalingPolicy(scalingPolicy);
}
}
if (topology.getGroups() != null) {
Set<String> nodeGroups = Sets.newHashSet();
for (Map.Entry<String, NodeGroup> groupEntry : topology.getGroups().entrySet()) {
if (groupEntry.getValue().getMembers() != null && groupEntry.getValue().getMembers().contains(templateEntry.getKey())) {
nodeGroups.add(groupEntry.getKey());
}
}
paaSNodeTemplate.setGroups(nodeGroups);
}
nodeTemplates.put(templateEntry.getKey(), paaSNodeTemplate);
}
}
return nodeTemplates;
}
use of alien4cloud.paas.model.PaaSRelationshipTemplate in project alien4cloud by alien4cloud.
the class PaaSUtils method processRelationshipTemplateProperties.
/**
* Inject relationshipTemplate, source, target and targeted capability properties as input parameters for all its interfaces operations <br>
* The injected input names are uppercased and is in form:
* <ul>
* <li>{@code SELF_<PROPERTY_NAME>} for relationship property
* <li>{@code SOURCE_<PROPERTY_NAME>} for source property
* <li>{@code TARGET_<PROPERTY_NAME>} for target property
* <li>{@code TARGET_CAPABILITIES_<CAPABILITY_NAME>_<PROPERTY_NAME>} for capability property
* </ul>
* In case of name conflict, the overriding order is: (--> = overrides)
*
* <pre>
* declared input --> relationship property input --> source property input --> target property input --> targeted capability property input
* </pre>
*
* @param paaSRelationshipTemplate The {@link PaaSRelationshipTemplate} to process
* @param paaSNodeTemplates All the nodes of the topology
*/
public static void processRelationshipTemplateProperties(PaaSRelationshipTemplate paaSRelationshipTemplate, Map<String, PaaSNodeTemplate> paaSNodeTemplates) {
RelationshipTemplate template = paaSRelationshipTemplate.getTemplate();
// inject relationship properties
injectPropertiesAsInputs(ToscaFunctionConstants.SELF, null, template.getProperties(), paaSRelationshipTemplate.getInterfaces(), baseName -> StringUtils.joinWith(AlienUtils.DEFAULT_PREFIX_SEPARATOR, ToscaFunctionConstants.SELF, baseName));
// inject source properties
injectSourcePropertiesAsInputs(paaSNodeTemplates.get(paaSRelationshipTemplate.getSource()), paaSRelationshipTemplate.getInterfaces());
// inject target properties
injectTargetPropertiesAsInputs(paaSNodeTemplates.get(template.getTarget()), paaSRelationshipTemplate.getInterfaces());
// inject related target capability properties
injectTargetedCapabilityProperties(paaSNodeTemplates.get(template.getTarget()), template.getTargetedCapabilityName(), paaSRelationshipTemplate.getInterfaces());
}
use of alien4cloud.paas.model.PaaSRelationshipTemplate in project alien4cloud by alien4cloud.
the class ServiceResourceRelationshipService method processService.
private void processService(PaaSNodeTemplate paaSNodeTemplate) {
ServiceNodeTemplate serviceNodeTemplate = (ServiceNodeTemplate) paaSNodeTemplate.getTemplate();
ServiceResource serviceResource = serviceResourceService.getOrFail(serviceNodeTemplate.getServiceResourceId());
for (PaaSRelationshipTemplate paaSRelationshipTemplate : paaSNodeTemplate.getRelationshipTemplates()) {
Interface templateInterface = safe(paaSRelationshipTemplate.getInterfaces()).get(ToscaRelationshipLifecycleConstants.CONFIGURE);
if (templateInterface != null) {
if (paaSRelationshipTemplate.getSource().equals(paaSNodeTemplate.getId())) {
processSourceOperations(paaSRelationshipTemplate, serviceResource, templateInterface);
} else {
processTargetOperations(paaSRelationshipTemplate, serviceResource, templateInterface);
}
}
}
}
Aggregations