forked from pool/cloud-init
Robert Schweikert
f30a915a55
+ When the user configures a new rules file for network devices the rules may not apply immediately, trigger udevadm OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/cloud-init?expand=0&rev=136
36 lines
1.6 KiB
Diff
36 lines
1.6 KiB
Diff
--- cloudinit/net/sysconfig.py.orig
|
|
+++ cloudinit/net/sysconfig.py
|
|
@@ -15,6 +15,7 @@ from .network_state import (
|
|
is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6)
|
|
|
|
LOG = logging.getLogger(__name__)
|
|
+PERS_NET_RULES_DEFAULT = 'etc/udev/rules.d/70-persistent-net.rules'
|
|
|
|
|
|
def _make_header(sep='#'):
|
|
@@ -276,7 +277,7 @@ class Renderer(renderer.Renderer):
|
|
config = {}
|
|
self.sysconf_dir = config.get('sysconf_dir', 'etc/sysconfig')
|
|
self.netrules_path = config.get(
|
|
- 'netrules_path', 'etc/udev/rules.d/70-persistent-net.rules')
|
|
+ 'netrules_path', PERS_NET_RULES_DEFAULT)
|
|
self.dns_path = config.get('dns_path', 'etc/resolv.conf')
|
|
nm_conf_path = 'etc/NetworkManager/conf.d/99-cloud-init.conf'
|
|
self.networkmanager_conf_path = config.get('networkmanager_conf_path',
|
|
@@ -676,6 +677,15 @@ class Renderer(renderer.Renderer):
|
|
netrules_content = self._render_persistent_net(network_state)
|
|
netrules_path = util.target_path(target, self.netrules_path)
|
|
util.write_file(netrules_path, netrules_content, file_mode)
|
|
+ # Making the assumption that the configured file is in a sane
|
|
+ # location
|
|
+ if (
|
|
+ os.path.basename(PERS_NET_RULES_DEFAULT)
|
|
+ != os.path.basename(netrules_path)
|
|
+ ):
|
|
+ util.subp(
|
|
+ ['udevadm', 'trigger', '-a ACTION=add', '-a SUBSYSTEM=net']
|
|
+ )
|
|
|
|
sysconfig_path = util.target_path(target, templates.get('control'))
|
|
# Distros configuring /etc/sysconfig/network as a file e.g. Centos
|