← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~rjschwei/cloud-init:netV1ToTranslate into cloud-init:master

 


Diff comments:

> diff --git a/cloudinit/distros/net_util.py b/cloudinit/distros/net_util.py
> index 1ce1aa7..fad062d 100644
> --- a/cloudinit/distros/net_util.py
> +++ b/cloudinit/distros/net_util.py
> @@ -148,6 +160,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:

This could be more flexible (of whitespace between default,  gw and ip addr) with something like:
match = re.match('.*default\s+gw\s+(?P<gateway>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}).*', route_info)
if match:
    iface_info['gateway'] = match.group('gateway')

> +                            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:


-- 
https://code.launchpad.net/~rjschwei/cloud-init/+git/cloud-init/+merge/333904
Your team cloud-init commiters is requested to review the proposed merge of ~rjschwei/cloud-init:netV1ToTranslate into cloud-init:master.


References