LGTM,

Thanks,

Guido
On 10 Apr 2013 08:42, "Helga Velroyen" <[email protected]> wrote:

> When creating a network, so far no size constraints were checked.
> We now limit the size of a network to a /30 or bigger, although
> tecnically, the ipaddr library supports even /32 networks.
>
> Signed-off-by: Helga Velroyen <[email protected]>
> Reviewed-by: Michael Hanselmann <[email protected]>
> ---
>  lib/network.py | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/lib/network.py b/lib/network.py
> index a1c51c5..170a8b7 100644
> --- a/lib/network.py
> +++ b/lib/network.py
> @@ -29,6 +29,9 @@ from bitarray import bitarray
>
>  from ganeti import errors
>
> +IPV4_NETWORK_MIN_SIZE = 30
> +IPV4_NETWORK_MIN_NUM_HOSTS = 2 ** (32 - IPV4_NETWORK_MIN_SIZE)
> +
>
>  class AddressPool(object):
>    """Address pool class, wrapping an C{objects.Network} object.
> @@ -55,6 +58,12 @@ class AddressPool(object):
>      self.net = network
>
>      self.network = ipaddr.IPNetwork(self.net.network)
> +    if self.network.numhosts < IPV4_NETWORK_MIN_NUM_HOSTS:
> +      raise errors.AddressPoolError("A network with only %s host(s) is
> too"
> +                                    " small, please specify at least a
> /%s"
> +                                    " network" %
> +                                    (str(self.network.numhosts),
> +                                     IPV4_NETWORK_MIN_SIZE))
>      if self.net.gateway:
>        self.gateway = ipaddr.IPAddress(self.net.gateway)
>
> --
> 1.8.1.3
>
>

Reply via email to