--- cloudinit/distros/net_util.py.orig +++ cloudinit/distros/net_util.py @@ -67,6 +67,10 @@ # } # } +import re + +ipv4 = re.compile("\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}") + def translate_network(settings): # Get the standard cmd, args from the ubuntu format entries = [] @@ -88,7 +92,14 @@ def translate_network(settings): consume = {} consume[cmd] = args else: - consume[cmd] = args + if consume.get(cmd): + val = consume[cmd] + if isinstance(val, list): + consume[cmd].append(args) + else: + consume[cmd] = [val, args] + else: + consume[cmd] = args # Check if anything left over to consume absorb = False for (cmd, args) in consume.items(): @@ -148,6 +159,16 @@ def translate_network(settings): hw_addr = hw_split[1] if hw_addr: iface_info['hwaddress'] = hw_addr + if 'post-up' in info: + routes = info['post-up'] + if isinstance(routes, list): + for route_info in routes: + if 'default gw' in route_info: + iface_info['gateway'] = ipv4.search( + route_info).group(0) + elif 'default gw' in routes: + iface_info['gateway'] = ipv4.search(routes).group(0) + # If ipv6 is enabled, device will have multiple IPs, so we need to # update the dictionary instead of overwriting it... if dev_name in real_ifaces: