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

Properties from relationships in xOpera 0.7.0 #257

Open R4pinho opened 1 year ago

R4pinho commented 1 year ago

Description

In xOpera 0.7.0 version I can't use properties from nodes used in a relationship. So for example, let's say that I'm trying to do this:

vm_ip: { value: { get_attribute: [ SELF, binding, public_address ] }, type: string }

I get this following error:

AttributeError: 'Node' object has no attribute 'get_property'

I was able to identify the error coming from the src/opera/instance/node.py line 295:

return requirements[0].target.get_property([OperationHost.SELF.value] + rest)

The error comes from the xopera-tosca-parser library not having get_property() function defined in the Node class. I was able to write a quick fix for this error, but I also saw that you have this comment: TODO: Add support for nested property values, maybe it is a known bug, just wanted to get a confirmation from you.

The get_property also doens't work with capabilities using hosted_on relationship. So let's say I have this:

distribution: { value: { get_property: [ HOST, os, distribution ] }, type: string }

The distribution is a property from os capability defined in the host node.

Both examples trigger a error using xOpera 0.70 but were fine using previous versions

anzoman commented 1 year ago

Hi @R4pinho and many thanks for opening this. Can you provide your full TOSCA template or CSAR just to be clearer?

R4pinho commented 1 year ago

Sorry @anzoman, I'm afraid I can't share the full TOSCA template due to the project I'm working on. However, let's say the node in question is derived from tosca.nodes.network.Port normative type. This node is instantiaded as follows:

port:
      type: node_example
      properties:
        mac_address: 02:00:00:b3:03:46
        vlan: trunk
      requirements:
      - link: network
      - binding: vm0

I pretend to use vm0 IP as a input by doing this in the node_example definition: vm_ip: { value: { get_attribute: [ SELF, binding, public_address ] }, type: string }

This worked on versions 0.6.8 and 0.6.9 but is not working in version 0.7.0.

The second error comes from trying to get the VM capabilities on hosted on components. VM nodes are derived from Compute normative types, which have the os capability (architecture, type and distribution). What I want is get the distribution as an input like this:

distribution: { value: { get_property: [ HOST, os, distribution ] }, type: string }