From 35faddb8cdec69b2ffb66e2369c7550fa9342c1e Mon Sep 17 00:00:00 2001 From: James Polley Date: Sat, 22 Nov 2014 10:47:07 +0100 Subject: 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 --- os_net_config/impl_eni.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'os_net_config/impl_eni.py') 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" % ( -- cgit 1.2.3-korg