oasis-open / tosca-community-contributions

OASIS TC Open Repository: Manages TOSCA profiles, tests, and templates that are maintained by the TOSCA community. They are intended to be used as examples to help developers get started with TOSCA and to test compliance of TOSCA implementations with the standard.
https://github.com/oasis-open/tosca-community-contributions
Apache License 2.0
39 stars 25 forks source link

Substitution mapping and selectable nodes #164

Open lauwers opened 6 months ago

lauwers commented 6 months ago

I'd like to add support for mapping requirements to selectable nodes. I have a common use case where a host requirement in a substituted node needs to be mapped multiple times (to each of the host requirements of the nodes in the substituting template). Rather than defining multiple mappings, it would be more elegant to define a selectable host node in the substituting template and map the host requirement once to the selectable node. I think this could be done elegantly using a simple extension to the requirement mapping syntax as follows:

service_template:
  substitution_mappings:
    requirements:
      - server: [client, server] # traditional requirement mapping
      - host: compute # mapping to selectable node
  node_templates:
    client:
      type: Client
      requirements:
        - server:
            count: 1
       - host: host
    compute:
      type: Compute
      directives: [select]