forked from pool/cloud-init
Robert Schweikert
ddfb957280
+ Properly handle static routes. The EphemeralDHCP context manager did not parse or handle rfc3442 classless static routes which prevented reading datasource metadata in some clouds. - Update cloud-init-trigger-udev.patch (bsc#1144363) - The __str__ implementation no longer delivers the name of the interface, use the "name" attribute instead to form a proper path in the sysfs tree - Update cloud-init-write-routes.patch (bsc#1144881) + If no routes are set for a subnet but the subnet has a gateway specified, set the gateway as the default route for the interface OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=144
53 lines
2.4 KiB
Diff
53 lines
2.4 KiB
Diff
--- cloudinit/distros/opensuse.py.orig
|
|
+++ cloudinit/distros/opensuse.py
|
|
@@ -172,7 +172,48 @@ class Distro(distros.Distro):
|
|
util.write_file(out_fn, str(conf), 0o644)
|
|
|
|
def _write_network_config(self, netconfig):
|
|
- 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
|
|
+ self._write_routes(netconfig)
|
|
+ return net_apply_res
|
|
+
|
|
+ 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', [])
|
|
+ config_routes = ''
|
|
+ for subnet in subnets:
|
|
+ routes = subnet.get('routes', [])
|
|
+ for route in routes:
|
|
+ dest = route.get('network')
|
|
+ if dest in default_nets:
|
|
+ dest = 'default'
|
|
+ gateway = route.get('gateway')
|
|
+ config_routes += ' '.join([dest, gateway])
|
|
+ if dest != 'default':
|
|
+ config_routes += ' ' + route.get('netmask', '')
|
|
+ else:
|
|
+ config_routes += ' -'
|
|
+ config_routes += ' -'
|
|
+ config_routes += '\n'
|
|
+ if not config_routes:
|
|
+ dest = 'default'
|
|
+ gateway = subnet.get('gateway')
|
|
+ if gateway:
|
|
+ config_routes += ' '.join(
|
|
+ [dest, gateway, '-', '-', '\n']
|
|
+ )
|
|
+ if config_routes:
|
|
+ route_file = '/etc/sysconfig/network/ifroute-%s' % if_name
|
|
+ util.write_file(route_file, config_routes)
|
|
|
|
@property
|
|
def preferred_ntp_clients(self):
|