how to substitue a node with substitution_mappings in other template

Asked by futangw on 2016-12-15

I have defined a topology template as below (file 1) to define a substitution_mappings. With this file, i can on board VNF catalog successfully.

File 1:
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0

topology_template:
  description: Template of a database including its hosting stack.

  substitution_mappings:
    node_type: tosca.nodes.Database
    capabilities:
      database_endpoint: [ database, database_endpoint ]

  node_templates:
    database:
      type: tosca.nodes.Database
      properties:
        user: dbuser
        password: abcdeft
      requirements:
        - host: dbms

    dbms:
      type: tosca.nodes.DBMS
      properties:
        root_password: abcd
        port: 3306
      requirements:
        - host: server

    server:
      type: tosca.nodes.nfv.VDU.Tacker
      capabilities:
        nfv_compute:
          properties:
            num_cpus: 1
            mem_size: 512 MB
            disk_size: 2 GB
      properties:
        image: cirros-0.3.0
        availability_zone: nova

But I always failed when I on board another template file (file 2) below where it has requirements of 'database_endpoint'.
what do i missed?

file 2:
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0

topology_template:
  description: Template of an application connecting to a database.

  node_templates:
    web_app:
      type: tosca.nodes.WebApplication
      requirements:
        - host: web_server
        - database_endpoint: db
    web_server:
      type: tosca.nodes.WebServer
      requirements:
        - host: server

    server:
      type: tosca.nodes.nfv.VDU.Tacker
      capabilities:
        nfv_compute:
          properties:
            num_cpus: 1
            mem_size: 512 MB
            disk_size: 1 GB
      properties:
        image: cirros-0.3.0
        availability_zone: nova

    db:
      type: tosca.nodes.Database
      properties:
        user: my_db_user
        password: secret
        name: my_db_name

it returns:
tosca-parser failed: -
The pre-parsed input failed validation with the following error(s):

UnknownFieldError: "requirements" of template "web_app" contains unknown field "database_endpoint". Refer to the definition to verify valid values.

thanks for your kind help.

regards,
futangw

Question information

Language:
English Edit question
Status:
Solved
For:
tacker Edit question
Assignee:
No assignee Edit question
Solved by:
Bob Haddleton
Solved:
2016-12-16
Last query:
2016-12-16
Last reply:
2016-12-15
Best Bob Haddleton (bob-haddleton) said : #1

Hi Futangw:

The parser is complaining because the tosca.nodes.WebApplication node definition does not include a requirement for a database_endpoint:

https://github.com/openstack/tosca-parser/blob/master/toscaparser/elements/TOSCA_definition_1_0.yaml#L162

It only has a requirement for a host.

futangw (futangw) said : #2

Hi, Bob,

thanks for the answer. I understand it now. This may also answer my other question #406778 that why failed to use tosca.nodes.DBMS.MySQL since it is not defined in TOSCA_definition_1_0.yaml file. So looks not all the nodes type defined in 'TOSCA Simple Profile in YAML Version 1.0' was already supported? I'm using tosca-parser-0.6.0.

Regards,
Futangw

futangw (futangw) said : #3

Thanks Bob Haddleton, that solved my question.