From c0389cada9491199fd4cc64dad6edc73960d39be Mon Sep 17 00:00:00 2001 From: Yolanda Robla Mota Date: Wed, 24 Aug 2016 17:40:58 +0200 Subject: [PATCH] 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 --- glean/cmd.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/glean/cmd.py b/glean/cmd.py index 4767cc4..e795b54 100644 --- a/glean/cmd.py +++ b/glean/cmd.py @@ -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?