nic config conversion script fails if input file has blank line followed by comment

Bug #1779191 reported by Bob Fournier
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
tripleo-heat-templates (Ubuntu)
New
Undecided
Bob Fournier

Bug Description

The script to convert nic config files from old-style to new-style will fail if the the input yaml file has a blank like followed by a comment, like this:
               -
                  type: vlan
                  vlan_id: {get_param: TenantNetworkVlanID}
                  addresses:
                    -
                      ip_netmask: {get_param: TenantIpSubnet}

                # Uncomment when including environments/network-management.yaml
                -
                  type: vlan
                  vlan_id: {get_param: ManagementNetworkVlanID}
                  addresses:
                    -
                      ip_netmask: {get_param: ManagementIpSubnet}

It will result in this error:
Converting nic-configs/controller.yaml
Traceback (most recent call last):
  File "/usr/share/openstack-tripleo-heat-templates/tools/yaml-nic-config-2-script.py", line 155, in convert
    tpl = yaml.load(open(filename).read(), Loader=TemplateLoader)
  File "/usr/lib64/python2.7/site-packages/yaml/__init__.py", line 71, in load
    return loader.get_single_data()
  File "/usr/lib64/python2.7/site-packages/yaml/constructor.py", line 37, in get_single_data
    node = self.get_single_node()
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 36, in get_single_node
    document = self.compose_document()
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 55, in compose_document
    node = self.compose_node(None, None)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 127, in compose_mapping_node
    while not self.check_event(MappingEndEvent):
  File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 98, in check_event
    self.current_event = self.state()
  File "/usr/lib64/python2.7/site-packages/yaml/parser.py", line 439, in parse_block_mapping_key
    "expected <block end>, but found %r" % token.id, token.start_mark)
ParserError: while parsing a block mapping
  in "<string>", line 1, column 1:
    heat_template_version: 2015-04-30
    ^
expected <block end>, but found '<block sequence start>'
  in "<string>", line 171, column 13:

This is because the first pass of converting the file doesn't properly indent the commented line if its preceded by a blank line.

Bob Fournier (bfournie)
Changed in tripleo-heat-templates (Ubuntu):
assignee: nobody → Bob Fournier (bfournie)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 9.0.0.0b4

This issue was fixed in the openstack/tripleo-heat-templates 9.0.0.0b4 development milestone.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/tripleo-heat-templates 8.0.5

This issue was fixed in the openstack/tripleo-heat-templates 8.0.5 release.

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.