Add check to skip bridge interfaces

On the use case that a bridge is configured, glean
shall skip it, and not try to perform any configuration.

Change-Id: I97334047d61f604ad5f51a3de8c08da4d93f59aa
This commit is contained in:
Yolanda Robla Mota 2016-08-24 17:40:58 +02:00
parent 1cc6d21144
commit c0389cada9
1 changed files with 22 additions and 0 deletions

View File

@ -679,6 +679,23 @@ def is_interface_vlan(iface):
return False
def is_interface_bridge(iface, distro):
if distro in ('debian', 'ubuntu'):
file_name = '/etc/network/interfaces.d/%s.cfg' % iface
if os.path.exists(file_name):
return 'bridge_ports' in open(file_name).read().lower()
elif distro in ('redhat', 'centos', 'fedora', 'suse', 'opensuse'):
file_name = '/etc/sysconfig/network-scripts/ifcfg-%s' % iface
if os.path.exists(file_name):
return 'type=bridge' in open(file_name).read().lower()
elif distro in ('gentoo'):
file_name = '/etc/conf.d/net.%s' % iface
if os.path.exists(file_name):
return 'bridge' in open(file_name).read().lower()
return False
def get_sys_interfaces(interface, args):
log.debug("Probing system interfaces")
sys_root = os.path.join(args.root, 'sys/class/net')
@ -698,6 +715,11 @@ def get_sys_interfaces(interface, args):
log.debug("Skipping vlan %s" % iface)
continue
# if interface is for an already configured bridge, skip it
if is_interface_bridge(iface, args.distro):
log.debug("Skipping bridge %s" % iface)
continue
mac_addr_type = open(
'%s/%s/addr_assign_type' % (sys_root, iface), 'r').read().strip()
# TODO why? is it not valid to configure randomly assigned mac addrs?