From 9d923c1ab9c4556b980509513ece4a414269b5b9 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Thu, 3 Aug 2017 16:38:09 -0400 Subject: net: Reduce duplicate code. Have get_interfaces_by_mac use get_interfaces. get_interfaces_by_mac and get_interfaces just looked much alike. This makes get_interfaces_by_mac call get_interfaces. --- cloudinit/net/__init__.py | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index 46cb9c85..1ff8fae0 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -511,21 +511,7 @@ def get_interfaces_by_mac(): Bridges and any devices that have a 'stolen' mac are excluded.""" ret = {} - devs = get_devicelist() - empty_mac = '00:00:00:00:00:00' - for name in devs: - if not interface_has_own_mac(name): - continue - if is_bridge(name): - continue - if is_vlan(name): - continue - mac = get_interface_mac(name) - # some devices may not have a mac (tun0) - if not mac: - continue - if mac == empty_mac and name != 'lo': - continue + for name, mac, _driver, _devid in get_interfaces(): if mac in ret: raise RuntimeError( "duplicate mac found! both '%s' and '%s' have mac '%s'" % -- cgit v1.2.3