Log the warning instead of raising an exception if input are not passed for tosca template raising

Bug #1653992 reported by bharaththiruveedula
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TOSCA Parser
Fix Released
Medium
bharaththiruveedula

Bug Description

When I tried to parser the below template I got an error.

TEMPLATE:
tosca_definitions_version: tosca_simple_yaml_1_0

description: Template for deploying a single server with predefined properties.

topology_template:
  inputs:
    num_cpu:
        type: integer
  node_templates:
    my_server:
      type: tosca.nodes.Compute
      capabilities:
        # Host container properties
        host:
         properties:
           num_cpus: {get_input: num_cpu}
           disk_size: 10 GB
           mem_size: 512 MB
        # Guest Operating System properties
        os:
          properties:
            # host Operating System image properties
            architecture: x86_64
            type: Linux
            distribution: RHEL
            version: 6.5

ERROR:
The input "tosca_helloworld.yaml" failed validation with the following error(s):

 MissingRequiredParameterError: Template is missing required parameter for input "num_cpu".
  File /usr/local/bin/tosca-parser, line 10, in <module>
   sys.exit(main())
  File /usr/local/lib/python2.7/dist-packages/toscaparser/shell.py, line 104, in main
   ParserShell().main(args)
  File /usr/local/lib/python2.7/dist-packages/toscaparser/shell.py, line 59, in main
   self.parse(path)
  File /usr/local/lib/python2.7/dist-packages/toscaparser/shell.py, line 68, in parse
   tosca = ToscaTemplate(path, None, a_file)
  File /usr/local/lib/python2.7/dist-packages/toscaparser/tosca_template.py, line 101, in __init__
   self.topology_template = self._topology_template()
  File /usr/local/lib/python2.7/dist-packages/toscaparser/tosca_template.py, line 119, in _topology_template
   None)
  File /usr/local/lib/python2.7/dist-packages/toscaparser/topology_template.py, line 55, in __init__
   self.inputs = self._inputs()
  File /usr/local/lib/python2.7/dist-packages/toscaparser/topology_template.py, line 83, in _inputs
   input_name=input.name))

But this is not required output for some use cases. Instead of raising an exception we need to log that error

Changed in tosca-parser:
assignee: nobody → bharaththiruveedula (bharath-ves)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to tosca-parser (master)

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

Changed in tosca-parser:
status: New → In Progress
Revision history for this message
Sahdev Zala (spzala) wrote :

There are cases where user may not want to provide any default e.g. password param or simply user want to provide value at the runtime so let's just log a warning message instead of failing.

Changed in tosca-parser:
importance: Undecided → Medium
Revision history for this message
Sahdev Zala (spzala) wrote :

Also in certain cases user may want to provide inputs via a separate configuration file at the runtime so logging only warning is more appropriate. If user miss providing such an input runtime failure should be considered as user error.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to tosca-parser (master)

Reviewed: https://review.openstack.org/416698
Committed: https://git.openstack.org/cgit/openstack/tosca-parser/commit/?id=ed70f10d7a9a8c439655c19334b1e40b6116a756
Submitter: Jenkins
Branch: master

commit ed70f10d7a9a8c439655c19334b1e40b6116a756
Author: Bharath Thiruveedula <email address hidden>
Date: Wed Jan 4 23:45:45 2017 +0530

    Log the required inputs, instead of raising exceptions

    Change-Id: If154aeebf277b3374aaff9c6b5d1d9522ea6c13c
    Closes-Bug: #1653992

Changed in tosca-parser:
status: In Progress → Fix Released
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.