From cb24b58c0dcd994d649316229db699213acd8432 Mon Sep 17 00:00:00 2001 From: Christophe Siraut Date: Fri, 12 Jun 2020 16:21:01 +0200 Subject: [PATCH] add bridge mode without macaddress --- dspawn/netconf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dspawn/netconf.py b/dspawn/netconf.py index 3e2696c..3cc47c4 100644 --- a/dspawn/netconf.py +++ b/dspawn/netconf.py @@ -10,6 +10,14 @@ modes = {'zone': '[Network]\nZone=Containers', nettpl_bridge = '''[Match] Name=host0 +[Network] +Address=%s/24 +Gateway=%s +DNS=%s''' + +nettpl_bridge_mac = '''[Match] +Name=host0 + [Network] Address=%s/32 Gateway=%s @@ -81,10 +89,13 @@ class MachineConfig: cf = os.path.join( self.machine.path, 'etc/systemd/network/80-container-host0.network') with open(cf, 'w') as fh: - if self.mode == 'bridge': + if self.mode == 'bridge' and self.macaddress: gw = get_default_gateway(self.macaddress) - fh.write(nettpl_bridge % (self.address, gw, nameserver, + fh.write(nettpl_bridge_mac % (self.address, gw, nameserver, self.macaddress)) + elif self.mode == 'bridge' and not self.macaddress: + gw = get_default_gateway(self.macaddress) + fh.write(nettpl_bridge % (self.address, gw, nameserver)) else: gw = '10.0.0.1' fh.write(nettpl % (self.address, gw))