From 3ca3be05875b4b95002d3c8635a8dbc45710285a Mon Sep 17 00:00:00 2001 From: BenjiReis Date: Fri, 2 Jun 2023 09:53:02 +0200 Subject: [PATCH] Maintenance: remove dead code of DebStyleInterface Now only RH Style are used so this code can be removed Solves: https://github.com/xenserver/host-installer/issues/46 Signed-off-by: BenjiReis --- netinterface.py | 23 ----------------------- netutil.py | 21 +-------------------- 2 files changed, 1 insertion(+), 43 deletions(-) diff --git a/netinterface.py b/netinterface.py index 63ccf5cf..d5c788db 100644 --- a/netinterface.py +++ b/netinterface.py @@ -137,29 +137,6 @@ def getBroadcast(self): bcast = output[10:].strip() return bcast - def writeDebStyleInterface(self, iface, f): - """ Write a Debian-style configuration entry for this interface to - file object f using interface name iface. """ - - # Debian style interfaces are only used for the installer; dom0 only uses CentOS style - # IPv6 is only enabled through answerfiles and so is not supported here. - assert self.modev6 is None - assert self.mode - iface_vlan = self.getInterfaceName(iface) - - if self.mode == self.DHCP: - f.write("iface %s inet dhcp\n" % iface_vlan) - else: - # CA-11825: broadcast needs to be determined for non-standard networks - bcast = self.getBroadcast() - f.write("iface %s inet static\n" % iface_vlan) - f.write(" address %s\n" % self.ipaddr) - if bcast is not None: - f.write(" broadcast %s\n" % bcast) - f.write(" netmask %s\n" % self.netmask) - if self.gateway: - f.write(" gateway %s\n" % self.gateway) - def writeRHStyleInterface(self, iface): """ Write a RedHat-style configuration entry for this interface to file object f using interface name iface. """ diff --git a/netutil.py b/netutil.py index 898fe0ea..f266695c 100644 --- a/netutil.py +++ b/netutil.py @@ -62,29 +62,10 @@ def rankValue(ethx): relevant.sort(lambda l, r: rankValue(l) - rankValue(r)) return relevant -# writes an 'interfaces' style file given a network configuration object list -def writeDebStyleInterfaceFile(configuration): - filename = '/etc/network/interfaces' - outfile = open(filename, 'w') - - outfile.write("auto lo\n") - outfile.write("iface lo inet loopback\n") - - for iface in configuration: - configuration[iface].writeDebStyleInterface(iface, outfile) - - outfile.close() - -def writeRHStyleInterfaceFiles(configuration): +def writeNetInterfaceFiles(configuration): for iface in configuration: configuration[iface].writeRHStyleInterface(iface) -def writeNetInterfaceFiles(configuration): - if os.path.isfile('/etc/sysconfig/network-scripts/ifcfg-lo'): - writeRHStyleInterfaceFiles(configuration) - else: - writeDebStyleInterfaceFile(configuration) - # writes DNS server entries to a resolver file given a network configuration object # list def writeResolverFile(configuration, filename):