← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~akaris/cloud-init:bug1679817-c into cloud-init:master

 

Hi,
I'm marking this as 'merged' based on the fact that the new merge proposal *is* merged.
(https://code.launchpad.net/~akaris/cloud-init/+git/cloud-init/+merge/324196)
Please move back to 'Needs Review' (and explain) if you think otherwise.



Diff comments:

> diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
> index d981277..d04ae8f 100644
> --- a/cloudinit/net/sysconfig.py
> +++ b/cloudinit/net/sysconfig.py
> @@ -102,9 +106,53 @@ class Route(ConfigMap):
>          return r
>  
>      @property
> -    def path(self):
> -        return self.route_fn_tpl % ({'base': self._base_sysconf_dir,
> -                                     'name': self._route_name})
> +    def path_ipv4(self):
> +        return self.route_fn_tpl_ipv4 % ({'base': self._base_sysconf_dir,
> +                                          'name': self._route_name})
> +
> +    @property
> +    def path_ipv6(self):
> +        return self.route_fn_tpl_ipv6 % ({'base': self._base_sysconf_dir,
> +                                          'name': self._route_name})
> +
> +    def is_ipv6_route(self, address):
> +        return ':' in address
> +
> +    def to_string(self, proto="ipv4"):
> +        buf = six.StringIO()
> +        buf.write(_make_header())
> +        if self._conf:
> +            buf.write("\n")
> +        # need to reindex IPv4 addresses
> +        # (because Route can contain a mix of IPv4 and IPv6)
> +        reindex = -1
> +        for key in sorted(self._conf.keys()):
> +            if 'ADDRESS' in key:
> +                index = key.replace('ADDRESS', '')
> +                address_value = str(self._conf[key])
> +                # only accept combinations:
> +                # ipv6 route and proto ipv6
> +                # ipv4 route and proto ipv4
> +                # do not add any other routes
> +                if proto == "ipv4" and not self.is_ipv6_route(address_value):
> +                    netmask_value = str(self._conf['NETMASK' + index])
> +                    gateway_value = str(self._conf['GATEWAY' + index])
> +                    # increase IPv4 index
> +                    reindex = reindex + 1
> +                    buf.write("%s=%s\n" % ('ADDRESS' + str(reindex),
> +                                           _quote_value(address_value)))
> +                    buf.write("%s=%s\n" % ('GATEWAY' + str(reindex),
> +                                           _quote_value(gateway_value)))
> +                    buf.write("%s=%s\n" % ('NETMASK' + str(reindex),
> +                                           _quote_value(netmask_value)))
> +                elif proto == "ipv6" and self.is_ipv6_route(address_value):
> +                    netmask_value = str(self._conf['NETMASK' + index])
> +                    gateway_value = str(self._conf['GATEWAY' + index])
> +                    buf.write("%s/%s via %s\n" % (address_value,
> +                                                  netmask_value,
> +                                                  gateway_value))

Shouldnt' we raise ValueError if neither of the above match?

> +
> +        return buf.getvalue()
>  
>  
>  class NetInterface(ConfigMap):


-- 
https://code.launchpad.net/~akaris/cloud-init/+git/cloud-init/+merge/324195
Your team cloud-init commiters is requested to review the proposed merge of ~akaris/cloud-init:bug1679817-c into cloud-init:master.


References