Matteo Scandolo | cb92e16 | 2017-10-03 13:12:30 -0700 | [diff] [blame] | 1 | |
| 2 | {% for m in proto.messages %} |
| 3 | |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 4 | tosca_definitions_version: tosca_simple_yaml_1_0 |
| 5 | |
| 6 | node_types: |
Matteo Scandolo | cb92e16 | 2017-10-03 13:12:30 -0700 | [diff] [blame] | 7 | |
Matteo Scandolo | 1fedfae | 2017-10-09 13:57:00 -0700 | [diff] [blame^] | 8 | # Example usage: |
| 9 | # |
| 10 | # <node-name>: |
| 11 | # type: tosca.nodes.{{ m.name }} |
| 12 | # properties: |
| 13 | # must-exist: true # optional to reference models created in other recipes |
| 14 | {%- for f in (m.fields + xproto_base_fields(m, proto.message_table)) | sort(attribute='name') %} |
| 15 | {%- if not f.link and xproto_tosca_required(f.options.null, f.options.blank, f.options.default) %} |
| 16 | # {{ f.name }}: <value> |
| 17 | {%- endif -%} |
| 18 | {%- endfor %} |
| 19 | |
| 20 | |
| 21 | |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 22 | tosca.nodes.{{ m.name }}: |
| 23 | derived_from: tosca.nodes.Root |
Matteo Scandolo | 4c14b62 | 2017-08-17 12:25:18 -0700 | [diff] [blame] | 24 | description: {% if m.options.description -%}{{ m.options.description}}{% else%}"An XOS {{ m.name }}"{%- endif %} |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 25 | capabilities: |
| 26 | {{ m.name|lower }}: |
| 27 | type: tosca.capabilities.xos.{{ m.name }} |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 28 | properties: |
Matteo Scandolo | d12be21 | 2017-07-07 10:44:34 -0700 | [diff] [blame] | 29 | must-exist: |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 30 | type: boolean |
| 31 | default: false |
Matteo Scandolo | d12be21 | 2017-07-07 10:44:34 -0700 | [diff] [blame] | 32 | description: Allow to reference existing models in TOSCA recipes |
Matteo Scandolo | cb92e16 | 2017-10-03 13:12:30 -0700 | [diff] [blame] | 33 | {% for f in (m.fields + xproto_base_fields(m, proto.message_table)) | sort(attribute='name') %} |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 34 | {%- if not f.link -%} |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 35 | {{ f.name }}: |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 36 | type: {{ xproto_tosca_field_type(f.type) }} |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 37 | required: {{ xproto_tosca_required(f.options.null, f.options.blank, f.options.default) }} |
| 38 | description: {{ f.options.help_text }} |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 39 | {% endif %} |
Matteo Scandolo | 9ce1825 | 2017-06-22 10:48:25 -0700 | [diff] [blame] | 40 | {%- endfor %} |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 41 | |
| 42 | {% for l in m.links %} |
| 43 | {%- if l.link_type == "manytoone" -%} |
Matteo Scandolo | 1fedfae | 2017-10-09 13:57:00 -0700 | [diff] [blame^] | 44 | |
| 45 | |
| 46 | # Identify a {{ l.peer.name }} that belongs to a {{ m.name }} |
| 47 | # |
| 48 | # example usage: |
| 49 | # requirements: |
| 50 | # - {{ l.src_port }}: |
| 51 | # node: <node-name>: |
| 52 | # relationship: tosca.relationships.BelongsToOne |
| 53 | |
Matteo Scandolo | 485b713 | 2017-06-30 11:46:47 -0700 | [diff] [blame] | 54 | tosca.relationships.BelongsToOne: |
| 55 | derived_from: tosca.relationships.Root |
| 56 | valid_target_types: [ tosca.capabilities.xos.{{ l.peer.name }} ] |
| 57 | {%- endif%} |
| 58 | {%- if l.link_type == "manytomany" -%} |
| 59 | tosca.relationships.BelongsToMany: |
| 60 | derived_from: tosca.relationships.Root |
| 61 | valid_target_types: [ tosca.capabilities.xos.{{ l.peer.name }} ] |
| 62 | {%- endif%} |
| 63 | {% endfor %} |
| 64 | |
| 65 | tosca.capabilities.xos.{{ m.name }}: |
| 66 | derived_from: tosca.capabilities.Root |
| 67 | description: {{ m.name }} |
Matteo Scandolo | cb92e16 | 2017-10-03 13:12:30 -0700 | [diff] [blame] | 68 | |
| 69 | +++ {{ m.name }}.yaml |
| 70 | |
| 71 | {%- endfor %} |
| 72 | |