From 8867ff1bfbeb8a281e87de8c67d26abbff5bd5d0 Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 27 May 2016 12:03:07 +0200 Subject: [PATCH] Fixed defroute handling --- .gitignore | 3 +++ src/hostinfo/ifconfig.py | 26 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4cd5700 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/hostinfo +*.pyc +*~ diff --git a/src/hostinfo/ifconfig.py b/src/hostinfo/ifconfig.py index 6fc900c..13a58e9 100755 --- a/src/hostinfo/ifconfig.py +++ b/src/hostinfo/ifconfig.py @@ -89,6 +89,9 @@ def generate_ifcfgv4(tree, interface, search, nameservers): pass index = int('0%s' % index)+1 pass + if interface.defroute[0]: + config.append('DEFROUTE=%s' % interface.defroute[0]) + pass return config @@ -97,7 +100,15 @@ def generate_ifcfgv6(tree, interface, search, nameservers): if not interface_is_static(interface): config.append('IPV6INIT=yes') config.append('IPV6_AUTOCONF=yes') - config.append('IPV6_DEFROUTE=yes') + if interface.ipv6_defroute[0]: + config.append('IPV6_DEFROUTE=%s' % interface.ipv6_defroute[0]) + pass + elif interface.defroute[0]: + config.append('IPV6_DEFROUTE=%s' % interface.defroute[0]) + pass + else: + config.append('IPV6_DEFROUTE=yes') + pass config.append('IPV6_PEERDNS=yes') config.append('IPV6_PEERROUTES=yes') config.append('IPV6_FAILURE_FATAL=no') @@ -121,7 +132,15 @@ def generate_ifcfgv6(tree, interface, search, nameservers): if len(address): config.append('IPV6INIT=yes') config.append('IPV6_AUTOCONF=no') - config.append('IPV6_DEFROUTE=yes') + if interface.ipv6_defroute[0]: + config.append('IPV6_DEFROUTE=%s' % interface.ipv6_defroute[0]) + pass + elif interface.defroute[0]: + config.append('IPV6_DEFROUTE=%s' % interface.defroute[0]) + pass + else: + config.append('IPV6_DEFROUTE=yes') + pass config.append('IPV6_FAILURE_FATAL=no') config.append('IPV6ADDR=%s' % address[0]) if gateway: @@ -165,9 +184,6 @@ def generate_ifcfg(tree, interface): tmp = sorted(search, cmp=reverse_order) config.append('SEARCH="%s"' % (' '.join(tmp))) pass - if interface.defroute[0]: - config.append('DEFROUTE=%s' % interface.defroute[0]) - pass return '\n'.join(config) + '\n' -- GitLab