Bug 1594068 - yaml-nic-config-2-script.py breaks the nic templates when there's comments in the file
Summary: yaml-nic-config-2-script.py breaks the nic templates when there's comments in...
Keywords:
Status: CLOSED DUPLICATE of bug 1576572
Alias: None
Product: Red Hat OpenStack
Classification: Red Hat
Component: openstack-tripleo-heat-templates
Version: 13.0 (Queens)
Hardware: Unspecified
OS: Unspecified
unspecified
urgent
Target Milestone: ---
: ---
Assignee: Emilien Macchi
QA Contact: Gurenko Alex
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-22 02:48 UTC by David Vallee Delisle
Modified: 2018-06-22 15:21 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-06-22 15:21:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description David Vallee Delisle 2018-06-22 02:48:00 UTC
Description of problem:
When running the yaml-nic-config-2-script.py on a yaml file with comments, We have a traceback (described below). There's still a backup of the original file taken, and the "new" file has an invalid value for bridge_name:

~~~
              name: {bridge_name}
~~~

The get_input command is missing in this case.

When we proceed with the "overcloud upgrade run" on the controller with these templates, we loose all network connectivity because os-net-config has a "null/None" name for one of the bridge. 

Version-Release number of selected component (if applicable):
openstack-tripleo-heat-templates-8.0.2-36.el7ost.noarch


How reproducible:
All the time

Steps to Reproduce:
1. Have comments in one of your nic templates
2. Run the converter script
3. proceed with the rest of the FFU procedure

Actual results:
~~~
(undercloud) [stack@undercloud-r430 nic-configs]$ /usr/share/openstack-tripleo-heat-templates/tools/yaml-nic-config-2-script.py test.yaml 
Using script at /usr/share/openstack-tripleo-heat-templates/network/scripts/run-os-net-config.sh
The yaml file will be overwritten and the original saved as /home/stack/hackfest/templates/nic-configs/test.yaml.20180621224142
Overwrite test.yaml? [y/n] y
Converting test.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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  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 133, in compose_mapping_node
    item_value = self.compose_node(node, item_key)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 82, in compose_node
    node = self.compose_sequence_node(anchor)
  File "/usr/lib64/python2.7/site-packages/yaml/composer.py", line 111, in compose_sequence_node
    node.value.append(self.compose_node(node, index))
  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 89, column 15:
                  type: interface # physical eth0, ...
                  ^
expected <block end>, but found '<block mapping start>'
  in "<string>", line 90, column 17:
                    inline_comment5: ' physical eth0 ...
                    ^
~~~

Expected results:
This script should either remove, or just ignore comments

Additional info:
This was found in the hackfest.

Comment 1 Bob Fournier 2018-06-22 15:21:48 UTC
Marking as dup of existing bug.

*** This bug has been marked as a duplicate of bug 1576572 ***


Note You need to log in before you can comment on or make changes to this bug.