Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate nodes with data from multiple nodes #255

Open
lterrac opened this issue Apr 27, 2022 · 4 comments
Open

Populate nodes with data from multiple nodes #255

lterrac opened this issue Apr 27, 2022 · 4 comments
Labels
TOSCA Something that considers TOSCA standard

Comments

@lterrac
Copy link

lterrac commented Apr 27, 2022

Hi everyone,

I am modelling an OOP programming language and I want to populate a node with attributes taken from other nodes.
I have a generic node class representing a class of the language. Every class has an attribute id which is assigned only when the class instance is created. The class has also has a property parameters to state the inputs passed to the class constructor and a requirement contractId to specify the dependency between classes

The node_types is:

class:
  ...
  requirements:
    contractId: ... -> based on DependsOn relationship
  attributes:
    id:
      type: string -> field populated after the node creation
  properties:
    parameters:
      type: list

The ServiceTemplate looks like the following:

classA:
  ... # Once the node is created an id value is stored in an attribute id

classB:
  ...

classC:
  requirements:
    - contractId: classA
    - contractId: classB

What I want to achieve is this translate in code:

A = contract()
B = contract()
C = contract(A.id, B.id)

The solution proposed in ServiceTemplate works fine if I have only one contractId requirement because I am able to retrieve the class id with { get_attribute: [SELF, contractId, id] } but it doesn't work with multiple requirements of the same type.
Am I missing something in the TOSCA specification/xopera implementation or this kind of operation can not be achieved? 😄

@lterrac
Copy link
Author

lterrac commented Apr 28, 2022

Sorry again, one last thought. This could be easily solved also if a way to merge lists exists. Then the problem can be modeled with a relationship where in the pos_configure_source (once the instance is created) the id is appended to an existing list. What I see (and understand) the current behaviour is that instead of doing an append() the lists are entirely replaced by the new value, am I right?

@lauwers
Copy link

lauwers commented Apr 28, 2022

In the Ubicity implementation, the get_attribute function automatically returns a list of values when multiple requirements exist of the same name.

@lterrac
Copy link
Author

lterrac commented May 2, 2022

Ok, thank you. I will look into it next time. As a temporary solution I created a list attribute which is incrementally populated by the playbook attached to the relationships. If anyone needs more information let me know and I will share the solution.

@anzoman
Copy link
Contributor

anzoman commented May 3, 2022

Hi @lterrac, thanks for opening this and nice that you found a temporary solution, for the future versions of opera we will also consider implementing the same behaviour as @lauwers has specified.

@anzoman anzoman added the TOSCA Something that considers TOSCA standard label May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TOSCA Something that considers TOSCA standard
Projects
None yet
Development

No branches or pull requests

3 participants