- Update cloud-init-write-routes.patch
+ In cases where the config contains 2 or more default gateway specifications for an interface only write the first default route, log warning message about skipped routes + Avoid writing invalid route specification if neither the network nor destination is specified in the route configuration OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=167
This commit is contained in:
parent
62128da3ea
commit
f618f6b3f1
@ -8,7 +8,7 @@
|
||||
|
||||
from cloudinit import helpers
|
||||
from cloudinit import log as logging
|
||||
@@ -172,7 +173,60 @@ class Distro(distros.Distro):
|
||||
@@ -172,7 +173,69 @@ class Distro(distros.Distro):
|
||||
util.write_file(out_fn, str(conf), 0o644)
|
||||
|
||||
def _write_network_config(self, netconfig):
|
||||
@ -31,6 +31,7 @@
|
||||
+ if_name = config.get('name')
|
||||
+ subnets = config.get('subnets', [])
|
||||
+ config_routes = ''
|
||||
+ has_default_route = False
|
||||
+ for subnet in subnets:
|
||||
+ # Render the default gateway if it is present
|
||||
+ gateway = subnet.get('gateway')
|
||||
@ -38,11 +39,12 @@
|
||||
+ config_routes += ' '.join(
|
||||
+ ['default', gateway, '-', '-\n']
|
||||
+ )
|
||||
+ has_default_route = True
|
||||
+ # Render subnet routes
|
||||
+ routes = subnet.get('routes', [])
|
||||
+ for route in routes:
|
||||
+ dest = route.get('destination') or route.get('network')
|
||||
+ if dest in default_nets:
|
||||
+ if not dest or dest in default_nets:
|
||||
+ dest = 'default'
|
||||
+ if dest != 'default':
|
||||
+ netmask = route.get('netmask')
|
||||
@ -51,19 +53,26 @@
|
||||
+ dest += '/' + str(prefix)
|
||||
+ if '/' not in dest:
|
||||
+ LOG.warning(
|
||||
+ 'Route destination has no prefix "%s"', dest
|
||||
+ 'Skipping route; has no prefix "%s"', dest
|
||||
+ )
|
||||
+ continue
|
||||
+ if dest == 'default' and has_default_route:
|
||||
+ LOG.warning(
|
||||
+ '%s already has default route, skipping "%s"',
|
||||
+ if_name, ' '.join([dest, gateway, '-', '-'])
|
||||
+ )
|
||||
+ continue
|
||||
+ if dest == 'default' and not has_default_route:
|
||||
+ has_default_route = True
|
||||
+ gateway = route.get('gateway')
|
||||
+ if not gateway:
|
||||
+ LOG.warning(
|
||||
+ 'Missing gateway for "%s", skipping', dest
|
||||
+ )
|
||||
+ continue
|
||||
+ config_routes += ' '.join(
|
||||
+ [dest, gateway, '-', '-\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)
|
||||
|
@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Fri Mar 27 12:21:00 UTC 2020 - Robert Schweikert <rjschwei@suse.com>
|
||||
|
||||
- Update cloud-init-write-routes.patch
|
||||
+ In cases where the config contains 2 or more default gateway
|
||||
specifications for an interface only write the first default route,
|
||||
log warning message about skipped routes
|
||||
+ Avoid writing invalid route specification if neither the network
|
||||
nor destination is specified in the route configuration
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 26 17:20:12 UTC 2020 - Robert Schweikert <rjschwei@suse.com>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user