Search in sources :

Example 1 with ArtifactSupport

use of alien4cloud.model.orchestrators.ArtifactSupport in project alien4cloud by alien4cloud.

the class LocationMatchNodesArtifactsElector method isEligible.

private boolean isEligible(AbstractInstantiableTemplate template, LocationMatchNodeFilter.NodeMatchContext matchContext) {
    if (template == null) {
        return true;
    }
    ArtifactSupport artifactSupport = matchContext.getArtifactSupport();
    // if no supported artifact defined, then return true
    if (artifactSupport == null || ArrayUtils.isEmpty(artifactSupport.getTypes())) {
        return true;
    }
    String[] supportedArtifacts = artifactSupport.getTypes();
    AbstractInstantiableToscaType indexedArtifactToscaElement = matchContext.getElement(AbstractInstantiableToscaType.class, template.getType());
    if (MapUtils.isNotEmpty(indexedArtifactToscaElement.getInterfaces())) {
        for (Interface interfaz : indexedArtifactToscaElement.getInterfaces().values()) {
            for (Operation operation : interfaz.getOperations().values()) {
                if (operation.getImplementationArtifact() != null) {
                    String artifactTypeString = operation.getImplementationArtifact().getArtifactType();
                    ArtifactType artifactType = matchContext.getElement(ArtifactType.class, artifactTypeString);
                    // stop the checking once one artifactType is not supported
                    if (!isFromOneOfTypes(supportedArtifacts, artifactType)) {
                        return false;
                    }
                }
            }
        }
    }
    return true;
}
Also used : ArtifactType(org.alien4cloud.tosca.model.types.ArtifactType) AbstractInstantiableToscaType(org.alien4cloud.tosca.model.types.AbstractInstantiableToscaType) Operation(org.alien4cloud.tosca.model.definitions.Operation) Interface(org.alien4cloud.tosca.model.definitions.Interface) ArtifactSupport(alien4cloud.model.orchestrators.ArtifactSupport)

Aggregations

ArtifactSupport (alien4cloud.model.orchestrators.ArtifactSupport)1 Interface (org.alien4cloud.tosca.model.definitions.Interface)1 Operation (org.alien4cloud.tosca.model.definitions.Operation)1 AbstractInstantiableToscaType (org.alien4cloud.tosca.model.types.AbstractInstantiableToscaType)1 ArtifactType (org.alien4cloud.tosca.model.types.ArtifactType)1