From 1791b5c2c271747dd141eceff82b8aa6356c81b7 Mon Sep 17 00:00:00 2001 From: BenjiReis Date: Mon, 7 Nov 2022 13:49:38 +0100 Subject: [PATCH] adapt to pr comments Signed-off-by: BenjiReis --- backend.py | 23 +++++++++++------------ upgrade.py | 7 +++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/backend.py b/backend.py index 68a8b8a8..57ae5c35 100644 --- a/backend.py +++ b/backend.py @@ -1546,18 +1546,17 @@ def configureNetworking(mounts, admin_iface, admin_bridge, admin_config, hn_conf # now we need to write /etc/sysconfig/network nfd = open("%s/etc/sysconfig/network" % mounts["root"], "w") nfd.write("NETWORKING=yes\n") - ipv6_conf = open("%s/etc/sysctl.d/91-net-ipv6.conf" % mounts["root"], "w") - if admin_config.modev6: - nfd.write("NETWORKING_IPV6=yes\n") - util.runCmd2(['chroot', mounts['root'], 'systemctl', 'enable', 'ip6tables']) - for i in ['all', 'default']: - ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=0\n' % i) - else: - nfd.write("NETWORKING_IPV6=no\n") - for i in ['all', 'default']: - ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=1\n' % i) - netutil.disable_ipv6_module(mounts["root"]) - ipv6_conf.close() + with open("%s/etc/sysctl.d/91-net-ipv6.conf" % mounts["root"], "w") as ipv6_conf: + if admin_config.modev6: + nfd.write("NETWORKING_IPV6=yes\n") + util.runCmd2(['chroot', mounts['root'], 'systemctl', 'enable', 'ip6tables']) + for i in ['all', 'default']: + ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=0\n' % i) + else: + nfd.write("NETWORKING_IPV6=no\n") + for i in ['all', 'default']: + ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=1\n' % i) + netutil.disable_ipv6_module(mounts["root"]) nfd.write("IPV6_AUTOCONF=no\n") nfd.write('NTPSERVERARGS="iburst prefer"\n') nfd.close() diff --git a/upgrade.py b/upgrade.py index 44d78859..f2bacc6a 100644 --- a/upgrade.py +++ b/upgrade.py @@ -476,10 +476,9 @@ def completeUpgrade(self, mounts, prev_install, target_disk, backup_partnum, log netutil.disable_ipv6_module(mounts["root"]) else: # Enable IPV6 - ipv6_conf = open("%s/etc/sysctl.d/91-net-ipv6.conf" % mounts["root"], "w") - for i in ['all', 'default']: - ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=0\n' % i) - ipv6_conf.close() + with open("%s/etc/sysctl.d/91-net-ipv6.conf" % mounts["root"], "w") as ipv6_conf: + for i in ['all', 'default']: + ipv6_conf.write('net.ipv6.conf.%s.disable_ipv6=0\n' % i) # handle the conversion of devices from aacraid to smartpqi primary_disk = self.source.getInventoryValue("PRIMARY_DISK")