Description of problem:
setupNetworks will fail with below error when an empty line is in ifcfg* files before "DEVICE" option.
==
MainProcess|jsonrpc.Executor/1::ERROR::2016-12-21 04:46:32,278::supervdsmServer::96::SuperVdsm.ServerCallback::(wrapper) Error in setupNetworks
Traceback (most recent call last):
File "/usr/share/vdsm/supervdsmServer", line 94, in wrapper
res = func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 249, in setupNetworks
_setup_networks(networks, bondings, options)
File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 277, in _setup_networks
netswitch.setup(networks, bondings, options, in_rollback)
File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 132, in setup
_setup_legacy(legacy_nets, legacy_bonds, options, in_rollback)
File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 153, in _setup_legacy
bondings, _netinfo)
File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 475, in add_missing_networks
_netinfo=_netinfo, **attrs)
File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 183, in wrapped
return func(network, configurator, **kwargs)
File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 254, in _add_network
net_ent_to_configure.configure(**options)
File "/usr/lib/python2.7/site-packages/vdsm/network/models.py", line 187, in configure
self.configurator.configureBridge(self, **opts)
File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 110, in configureBridge
File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 342, in normalize_device_filename
key, value = line.rstrip().split('=', 1)
ValueError: need more than 1 value to unpack
==
We are iterating through all ifcfg-* files and this will fails if there is a blank line before "DEVICE" in the configuration.
with open(ifcfg_file) as f:
for line in f:
if line.startswith('#'):
continue
key, value = line.rstrip().split('=', 1)
Version-Release number of selected component (if applicable):
vdsm-4.18.15.3-1.el7ev.x86_64
How reproducible:
100%
Steps to Reproduce:
1. Add a blank line before "DEVICE=" option in any of the ifcfg-* files.
2. Add a network from RHEV-M and setupNetworks will fail with mentioned error.
Actual results:
setupNetworks fails if there is an empty line in the ifcfg files
Expected results:
setupNetworks should run good by ignoring the empty lines.
Additional info:
(In reply to Dan Kenigsberg from comment #2)
> Any background who created the empty ifcfg file and why?
It's an empty line in the ifcfg file and not a complete empty file.
For the customer case, he was having a zip file named as "ifcfg-scripts.zip" which contains backup of the ifcfg file and hence this was failing with the mentioned error. After removing zip file, it was working good.
The issue can also happen if there is an empty line in any of the NICs configuration file. Attached log is from my test environment where I manually add a empty line in one of the configuration file to simulate the issue.
Description of problem: setupNetworks will fail with below error when an empty line is in ifcfg* files before "DEVICE" option. == MainProcess|jsonrpc.Executor/1::ERROR::2016-12-21 04:46:32,278::supervdsmServer::96::SuperVdsm.ServerCallback::(wrapper) Error in setupNetworks Traceback (most recent call last): File "/usr/share/vdsm/supervdsmServer", line 94, in wrapper res = func(*args, **kwargs) File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 249, in setupNetworks _setup_networks(networks, bondings, options) File "/usr/lib/python2.7/site-packages/vdsm/network/api.py", line 277, in _setup_networks netswitch.setup(networks, bondings, options, in_rollback) File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 132, in setup _setup_legacy(legacy_nets, legacy_bonds, options, in_rollback) File "/usr/lib/python2.7/site-packages/vdsm/network/netswitch.py", line 153, in _setup_legacy bondings, _netinfo) File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 475, in add_missing_networks _netinfo=_netinfo, **attrs) File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 183, in wrapped return func(network, configurator, **kwargs) File "/usr/lib/python2.7/site-packages/vdsm/network/legacy_switch.py", line 254, in _add_network net_ent_to_configure.configure(**options) File "/usr/lib/python2.7/site-packages/vdsm/network/models.py", line 187, in configure self.configurator.configureBridge(self, **opts) File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 110, in configureBridge File "/usr/lib/python2.7/site-packages/vdsm/network/configurators/ifcfg.py", line 342, in normalize_device_filename key, value = line.rstrip().split('=', 1) ValueError: need more than 1 value to unpack == We are iterating through all ifcfg-* files and this will fails if there is a blank line before "DEVICE" in the configuration. with open(ifcfg_file) as f: for line in f: if line.startswith('#'): continue key, value = line.rstrip().split('=', 1) Version-Release number of selected component (if applicable): vdsm-4.18.15.3-1.el7ev.x86_64 How reproducible: 100% Steps to Reproduce: 1. Add a blank line before "DEVICE=" option in any of the ifcfg-* files. 2. Add a network from RHEV-M and setupNetworks will fail with mentioned error. Actual results: setupNetworks fails if there is an empty line in the ifcfg files Expected results: setupNetworks should run good by ignoring the empty lines. Additional info: