Fix missing .cfg on exist_debian_interface function check

Glean should not overwrite network interfaces config files
if they already exist, per https://review.openstack.org/#/c/202984.
Glean writes Debian/Ubuntu network interface config files as
/etc/network/interfaces.d/<interface>.cfg, but the code checks
/etc/network/interfaces.d/<interface> prior to writing it.
Missing the .cfg extension on the string makes the check
to always evaluate to false, thus causing Glean to always overwrite
the network config files it may have created previously.
Also, checking the configuration file doesn't exist already
on the block of code for config drive interfaces.

Change-Id: I74bab07d3302752fe94c9182dc63ade25cd98c61
This commit is contained in:
Ricardo Carrillo Cruz 2015-12-02 13:35:04 +01:00
parent 92041b5a33
commit 0e75e6ca8b
2 changed files with 5 additions and 2 deletions

View File

@ -129,7 +129,7 @@ def write_redhat_interfaces(interfaces, sys_interfaces):
def _exists_debian_interface(name):
file_to_check = '/etc/network/interfaces.d/{name}'.format(name=name)
file_to_check = '/etc/network/interfaces.d/{name}.cfg'.format(name=name)
return os.path.exists(file_to_check)
@ -153,6 +153,9 @@ def write_debian_interfaces(interfaces, sys_interfaces):
interface_name = "{0}.{1}".format(vlan_raw_device,
interface['vlan_id'])
if _exists_debian_interface(interface_name):
continue
iface_path = os.path.join(eni_d_path, '%s.cfg' % interface_name)
if interface['type'] == 'ipv4_dhcp':

View File

@ -106,7 +106,7 @@ class TestGlean(base.BaseTestCase):
sample_data_path, sample_prefix,
path[1:])
if path in ['/etc/sysconfig/network-scripts/ifcfg-eth2',
'/etc/network/interfaces.d/eth2']:
'/etc/network/interfaces.d/eth2.cfg']:
# Pretend this file exists, we need to test skipping
# pre-existing config files
return True