From 7edf1ec946d34a905ebcd8ef27281e7aaf7e2b6e Mon Sep 17 00:00:00 2001 From: Artem Panchenko Date: Tue, 17 May 2016 19:22:56 +0300 Subject: [PATCH] Use first NIC with IP address by default Previously fuelmenu took first network interface (if it's not specified by user) as default option for admin NIC whether it has IP address or not. Now it tries to find a NIC with IP assigned, so it works fine without additional options when admin network is attached to not first interface. Change-Id: Iabd0ebb81af40b4f97f67df92403fcff7c268edf Related-bug: #1566557 --- fuelmenu/fuelmenu.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fuelmenu/fuelmenu.py b/fuelmenu/fuelmenu.py index b336cf7..f5c9d63 100755 --- a/fuelmenu/fuelmenu.py +++ b/fuelmenu/fuelmenu.py @@ -427,12 +427,18 @@ def main(*args, **kwargs): if urwid.VERSION < (1, 1, 0): print("This program requires urwid 1.1.0 or greater.") - try: - default_iface = network.get_physical_ifaces()[0] - except IndexError: + network_interfaces = network.get_physical_ifaces() + if not network_interfaces: print("Unable to detect any network interfaces. Could not start") sys.exit(1) + default_iface = network_interfaces[0] + + for nic in network_interfaces: + if network.is_interface_has_ip(nic): + default_iface = nic + break + parser = OptionParser() parser.add_option("-s", "--save-only", dest="save_only", action="store_true",