2019-01-18 10:50:54 +01:00
|
|
|
--- cloudinit/distros/opensuse.py.orig
|
|
|
|
+++ cloudinit/distros/opensuse.py
|
2019-11-08 16:05:12 +01:00
|
|
|
@@ -11,6 +11,7 @@
|
|
|
|
from cloudinit import distros
|
|
|
|
|
|
|
|
from cloudinit.distros.parsers.hostname import HostnameConf
|
|
|
|
+from cloudinit.net.network_state import mask_to_net_prefix
|
|
|
|
|
|
|
|
from cloudinit import helpers
|
|
|
|
from cloudinit import log as logging
|
|
|
|
@@ -172,7 +173,47 @@ class Distro(distros.Distro):
|
2019-01-18 10:50:54 +01:00
|
|
|
util.write_file(out_fn, str(conf), 0o644)
|
|
|
|
|
|
|
|
def _write_network_config(self, netconfig):
|
2019-02-22 17:22:45 +01:00
|
|
|
- return self._supported_write_network_config(netconfig)
|
|
|
|
+ net_apply_res = self._supported_write_network_config(netconfig)
|
|
|
|
+ # Clobber the route files that were written in RH key-value style
|
2019-01-18 10:50:54 +01:00
|
|
|
+ self._write_routes(netconfig)
|
2019-02-22 17:22:45 +01:00
|
|
|
+ return net_apply_res
|
|
|
|
+
|
2019-01-18 10:50:54 +01:00
|
|
|
+ def _write_routes(self, netconfig):
|
|
|
|
+ """Write route files, not part of the standard distro interface"""
|
|
|
|
+ # Due to the implementation of the sysconfig renderer default routes
|
|
|
|
+ # are setup in ifcfg-* files. But this does not work on SLES or
|
|
|
|
+ # openSUSE https://bugs.launchpad.net/cloud-init/+bug/1812117
|
|
|
|
+ # this is a very hacky way to get around the problem until a real
|
|
|
|
+ # solution is found in the sysconfig renderer
|
|
|
|
+ device_configs = netconfig.get('config', [])
|
|
|
|
+ default_nets = ('::', '0.0.0.0')
|
|
|
|
+ for config in device_configs:
|
|
|
|
+ if_name = config.get('name')
|
|
|
|
+ subnets = config.get('subnets', [])
|
2019-04-30 22:39:13 +02:00
|
|
|
+ config_routes = ''
|
2019-01-18 10:50:54 +01:00
|
|
|
+ for subnet in subnets:
|
|
|
|
+ routes = subnet.get('routes', [])
|
|
|
|
+ for route in routes:
|
|
|
|
+ dest = route.get('network')
|
|
|
|
+ if dest in default_nets:
|
|
|
|
+ dest = 'default'
|
|
|
|
+ if dest != 'default':
|
2019-11-08 16:05:12 +01:00
|
|
|
+ prefix = mask_to_net_prefix(route.get('netmask'))
|
|
|
|
+ dest += '/' + str(prefix)
|
|
|
|
+ gateway = route.get('gateway')
|
|
|
|
+ config_routes += ' '.join(
|
|
|
|
+ [dest, gateway, '-', '-\n']
|
|
|
|
+ )
|
2019-09-05 15:32:10 +02:00
|
|
|
+ if not config_routes:
|
|
|
|
+ dest = 'default'
|
|
|
|
+ gateway = subnet.get('gateway')
|
|
|
|
+ if gateway:
|
|
|
|
+ config_routes += ' '.join(
|
2019-11-08 16:05:12 +01:00
|
|
|
+ [dest, gateway, '-', '-\n']
|
2019-09-05 15:32:10 +02:00
|
|
|
+ )
|
2019-01-18 10:50:54 +01:00
|
|
|
+ if config_routes:
|
|
|
|
+ route_file = '/etc/sysconfig/network/ifroute-%s' % if_name
|
|
|
|
+ util.write_file(route_file, config_routes)
|
2019-02-22 17:22:45 +01:00
|
|
|
|
2019-01-18 10:50:54 +01:00
|
|
|
@property
|
|
|
|
def preferred_ntp_clients(self):
|