Custom definitions fail if parent definition has no properties

Bug #1830775 reported by Валерия Валерьевна Швецова
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
TOSCA Parser
New
Undecided
Unassigned

Bug Description

I have a problem with custom definitions when a parent definition doesn't have a properties field.
Custom definition file openstack-flavor-definition.yaml:

------------------------------------------------------------
tosca_definitions_version: tosca_simple_yaml_1_0

capability_types:
  openstack.capabilities.OpenstackRoot:
    derived_from: tosca.capabilities.Root

  openstack.capabilities.Flavor:
    derived_from: openstack.capabilities.OpenstackRoot
    properties:
      disk:
        type: scalar-unit.size
        required: false
      ephemeral:
        type: scalar-unit.size
        default: 0 GiB
      id:
        type: string
        required: false
      is_public:
        type: boolean
        default: true
      name:
        type: string
        required: true
      ram:
        type: scalar-unit.size
        required: false
      swap:
        type: scalar-unit.size
        default: 0 MiB
      vcpus:
        type: integer
        required: false

node_types:
  openstack.nodes.Flavor:
    derived_from: tosca.nodes.Root
    properties:
      extra_specs:
        type: map
        required: false
    capabilities:
      self:
        type: openstack.capabilities.Flavor
        occurrences: [ 1, 1 ]
------------------------------------------------------------

Template file openstack-flavor-template.yaml:
------------------------------------------------------------
tosca_definitions_version: tosca_simple_yaml_1_0

imports:
  - openstack-flavor-definition.yaml

topology_template:
  node_templates:
    m1.small:
      type: openstack.nodes.Flavor
      capabilities:
        self:
          properties:
            disk: 150 GiB
            name: m1.small
            ram: 2 GiB
            vcpus: 1
------------------------------------------------------------

The command:
tosca-parser --template openstack-flavor-template.yaml

Above command gets into error:
------------------------------------------------------------
Traceback (most recent call last):
  File "/home/user/virt-env/tosca-parser/bin/tosca-parser", line 10, in <module>
    sys.exit(main())
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/shell.py", line 116, in main
    ParserShell().main(args)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/shell.py", line 59, in main
    self.parse(path)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/shell.py", line 68, in parse
    tosca = ToscaTemplate(path, None, a_file)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/tosca_template.py", line 101, in __init__
    self.topology_template = self._topology_template()
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/tosca_template.py", line 120, in _topology_template
    None)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/topology_template.py", line 57, in __init__
    self.nodetemplates = self._nodetemplates()
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/topology_template.py", line 97, in _nodetemplates
    tpl.validate(self)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/nodetemplate.py", line 188, in validate
    self._validate_capabilities()
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/entity_template.py", line 184, in _validate_capabilities
    self._validate_capabilities_properties(capabilities)
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/entity_template.py", line 193, in _validate_capabilities_properties
    props[self.PROPERTIES])
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/entity_template.py", line 218, in _common_validate_properties
    for p in entitytype.get_properties_def_objects():
  File "/home/user/virt-env/tosca-parser/local/lib/python2.7/site-packages/toscaparser/elements/capabilitytype.py", line 44, in get_properties_def_objects
    for prop, schema in props.items():
AttributeError: 'NoneType' object has no attribute 'items'
------------------------------------------------------------

Expected output:

version: tosca_simple_yaml_1_0

nodetemplates:
 m1.small

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.