check networkd files

Previously we were checking Gentoo netifrc files (/etc/conf.d/net.{iname})
and not networkd files <F12>(/etc/systemd/network/{iname}.(netdev|network)).

Change to check for the networkd files.  This is not perfect as the file
name does not directly tie to the device name, but it's a start (it exists
as a Nmme or Match value within the file itself).

Change-Id: I6130102005ab61dfc25cd77c6e8abea38bccf201
This commit is contained in:
Matthew Thode 2018-10-12 09:41:42 -05:00
parent 9f629b8531
commit d87cf63a28
No known key found for this signature in database
GPG Key ID: 64A37BEAAE19A4E8
1 changed files with 7 additions and 1 deletions

View File

@ -535,7 +535,7 @@ def write_networkd_interfaces(interfaces, sys_interfaces):
for mac, iname in sorted(
sys_interfaces.items(), key=lambda x: x[1]):
if _exists_gentoo_interface(iname):
if _exists_networkd_interface(iname):
# This interface already has a config file, move on
log.debug("%s already has config file, skipping" % iname)
continue
@ -595,6 +595,12 @@ def write_networkd_interfaces(interfaces, sys_interfaces):
return files_to_write
def _exists_networkd_interface(name):
network_file = '/etc/systemd/network/{name}.network'.format(name=name)
netdev_file = '/etc/systemd/network/{name}.netdev'.format(name=name)
return (os.path.exists(network_file) or os.path.exists(netdev_file))
def _exists_gentoo_interface(name):
file_to_check = '/etc/conf.d/net.{name}'.format(name=name)
return os.path.exists(file_to_check)