Parameter handling for new TOSCA template broken

Bug #1593030 reported by Sridhar Ramaswamy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tacker
Fix Released
High
Bob Haddleton

Bug Description

When parameter values are passed to substitute parameters in the new TOSCA template format, vnf-create command errors out with "string indices must be integers" mesg

Error:

$ tacker vnf-create --name param1 --vnfd-name tosca-vnfd-params --param-file ./tosca-vnfd-param-inputs.yaml
tosca-parser failed: - string indices must be integers

Sample template with get_input,

topology_template:

  inputs:
    flavor_name:
      type: string
      description: The name of the machine flavor.
      default: m1.tiny
    image_name:
      type: string
      description: The name of the machine image.
      default: cirros-0.3.4-x86_64-uec

  node_templates:
    VDU1:
      type: tosca.nodes.nfv.VDU.Tacker
      properties:
        image: {get_input: image_name}
        flavor: {get_input: flavor_name}
        availability_zone: nova
        mgmt_driver: noop
        config: |
          param0: key1
          param1: key2

File with values for parameter,

$ cat ./tosca-vnfd-param-inputs.yaml
flavor_name: 'm1.medium',
image_name: 'cirros-0.3.4-x86_64-uec'

Revision history for this message
Sridhar Ramaswamy (srics-r) wrote :

Root cause is, tacker using a "string" param_values [1] and passes that to ToscaParser parsed_params [2] which expects it to be in json,

params = {'db_name': 'my_wordpress', 'db_user': 'my_db_user',
                  'db_root_pwd': 'mypasswd'}
        tosca = ToscaTemplate(parsed_params=params,
                              yaml_dict_tpl=yaml_dict_tpl)

Options to fix are,

a) convert the string param_values to json object before passing to ToscaTemplate
b) change the API / db to use json object to pass parameters

(b) is the preferred approach.

[1] https://github.com/openstack/tacker/blob/master/tacker/vm/infra_drivers/heat/heat.py#L288
[2] https://github.com/openstack/tacker/blob/master/tacker/vm/infra_drivers/heat/heat.py#L293

Revision history for this message
Sridhar Ramaswamy (srics-r) wrote :

Clarification on the preferred option..

Given this bug is also there in Mitaka, option (a) is better for time being as it will be easy to cherrypick to stable/mitaka branch.

option (b) involves API and DB changes which is not allowed in stable branches.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tacker (master)

Fix proposed to branch: master
Review: https://review.openstack.org/331304

Changed in tacker:
assignee: nobody → Bob Haddleton (bob-haddleton)
status: New → In Progress
Revision history for this message
Bob Haddleton (bob-haddleton) wrote :

One correction - the parameters can be passed as YAML, so no database change is needed. This should be the only fix needed.

Changed in tacker:
assignee: Bob Haddleton (bob-haddleton) → Sridhar Ramaswamy (srics-r)
Changed in tacker:
assignee: Sridhar Ramaswamy (srics-r) → Bob Haddleton (bob-haddleton)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tacker (master)

Reviewed: https://review.openstack.org/331304
Committed: https://git.openstack.org/cgit/openstack/tacker/commit/?id=db8fae5ef883f44eee5364d5d278c9a79b09b476
Submitter: Jenkins
Branch: master

commit db8fae5ef883f44eee5364d5d278c9a79b09b476
Author: Bob.Haddleton <email address hidden>
Date: Fri Jun 17 13:33:14 2016 -0500

    Convert parameters to dict before passing to TOSCA parser

    - Add a sample and test to validate parameters

    Co-Authored-By: <email address hidden>
    Co-Authored-By: <email address hidden>
    Change-Id: I8f7c36333ae26a88f52fe06883a9bfe8efdcf731
    Closes-bug: 1593030

Changed in tacker:
status: In Progress → Fix Released
Revision history for this message
Doug Hellmann (doug-hellmann) wrote : Fix included in openstack/tacker 0.4.0

This issue was fixed in the openstack/tacker 0.4.0 release.

Revision history for this message
Satish Verma (satishverma1999) wrote :

I am able to see this issue in Tacker 0.10.0. Is it fixed or still pending?
Pls share

Revision history for this message
Bob Haddleton (bob-haddleton) wrote :

The fix for this issue has been released. If there is still a problem it's either a new bug or an incomplete fix.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.