diff options
author | James Polley <jp@jamezpolley.com> | 2014-11-22 10:47:07 +0100 |
---|---|---|
committer | James Polley <jp@jamezpolley.com> | 2014-11-24 15:51:51 +0100 |
commit | 35faddb8cdec69b2ffb66e2369c7550fa9342c1e (patch) | |
tree | 14307ad3853b1a3576b2b5108994bf9403792d93 /os_net_config/impl_eni.py | |
parent | 2178678064417b2dc336dfb90ff3b0f431ab5555 (diff) |
If setting a default route, use default netmask
Without this change, when configuring a default route, it's neccessary
to explicitly provide an ip_netmask of 0.0.0.0/0 - otherwise line 177
errors because there's no route.ip_netmask.
With this change, it's still possible to provide an ip_netmask for a
default route (even though that makes no sense), but if none is provided
The Right Thing is done.
Change-Id: Idac59e571a72cc8d5693f811ec0121273b891d0f
Diffstat (limited to 'os_net_config/impl_eni.py')
-rw-r--r-- | os_net_config/impl_eni.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/os_net_config/impl_eni.py b/os_net_config/impl_eni.py index 87d45da..6c195fd 100644 --- a/os_net_config/impl_eni.py +++ b/os_net_config/impl_eni.py @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- Coding: utf-8 -*- # Copyright 2014 Red Hat, Inc. # @@ -174,7 +174,10 @@ class ENINetConfig(os_net_config.NetConfig): logger.info('adding custom route for interface: %s' % interface_name) data = "" for route in routes: - rt = netaddr.IPNetwork(route.ip_netmask) + if route.default and not route.ip_netmask: + rt = netaddr.IPNetwork("0.0.0.0/0") + else: + rt = netaddr.IPNetwork(route.ip_netmask) data += "up route add -net %s netmask %s gw %s\n" % ( str(rt.ip), str(rt.netmask), route.next_hop) data += "down route del -net %s netmask %s gw %s\n" % ( |