xlab-si / xopera-opera

xOpera orchestrator compliant with TOSCA YAML v1.3 in the making
https://xlab-si.github.io/xopera-docs/
Apache License 2.0
35 stars 14 forks source link

Property refinement not supported #246

Open philippemerle opened 2 years ago

philippemerle commented 2 years ago

Given the following template

tosca_definitions_version: tosca_simple_yaml_1_3

capability_types:
  TMFAPI:
    derived_from: tosca.capabilities.Node
    description: a TMForum defined REST API
    properties:
      id:
        type: string
        description: the id e.g TMF632
      name:
        type: string
        description: the name, e.g. party

  TMF632:
    derived_from: TMFAPI
    properties:
      id: TMF632
      name: party

then

$ opera validate template.yaml 
Validating service template...
template.yaml:19:11: [PropertyDefinition] Expected map.
$

According to both Section 3.6.10.6 and the last example of Section 3.6.10.8 of TOSCA v1.3, both lines 18 and 19 are correct.

Thank to @pmjordan for reporting this problem.

anzoman commented 2 years ago

Hi, @philippemerle thanks for opening this, I see that we should probably use ParameterDefinition instead of PropertyDefinition in src/opera/parser/tosca/v_1_3/capability_type.py (and also in other places where appropriate).

Still opera's TOSCA parser would expect a map (= dict) and to me refinement with just property_name: value (like id: TMF632 or name: party in your example) feels weird but if this is the correct syntax we would need to add additional possibility (XOR between map and direct value).

If I use ParameterDefinition in src/opera/parser/tosca/v_1_3/capability_type.py and change template to use a map type for property it goes through xOpera validation just fine:

tosca_definitions_version: tosca_simple_yaml_1_3

capability_types:
  TMFAPI:
    derived_from: tosca.capabilities.Node
    description: a TMForum defined REST API
    properties:
      id:
        type: string
        description: the id e.g TMF632
      name:
        type: string
        description: the name, e.g. party

  TMF632:
    derived_from: TMFAPI
    properties:
      id:
        value: TMF632
      name:
        value: party
philippemerle commented 2 years ago

According to Section 3.6.14.2 of TOSCA 1.3, the <parameter_name>: <parameter_value> | { <parameter_value_expression> } shall be supported. So you would need to add additional possibilities, i.e. map and direct value and value expression such as get_property.