summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorJames Falcon <james.falcon@canonical.com>2021-10-29 15:39:29 -0500
committerGitHub <noreply@github.com>2021-10-29 15:39:29 -0500
commita90d8338f07b30a46887f7c133baade63129a53a (patch)
treef432b1911b81b3f83ae56175b83d3df61a5779cd /cloudinit
parent0f8428f6227106c28615384d49a3e55e5c14dc17 (diff)
downloadvyos-cloud-init-a90d8338f07b30a46887f7c133baade63129a53a.tar.gz
vyos-cloud-init-a90d8338f07b30a46887f7c133baade63129a53a.zip
Allow libexec for hotplug (#1088)
When we added the install hotplug module, we forgot to update the redhet/cloud-init.spec.in file and allow for execution on /usr/libexec. This PR adds that functionality.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_install_hotplug.py10
-rw-r--r--cloudinit/sources/__init__.py1
2 files changed, 8 insertions, 3 deletions
diff --git a/cloudinit/config/cc_install_hotplug.py b/cloudinit/config/cc_install_hotplug.py
index d6b2a2df..da98c409 100644
--- a/cloudinit/config/cc_install_hotplug.py
+++ b/cloudinit/config/cc_install_hotplug.py
@@ -85,11 +85,11 @@ __doc__ = get_schema_doc(schema)
HOTPLUG_UDEV_PATH = "/etc/udev/rules.d/10-cloud-init-hook-hotplug.rules"
-HOTPLUG_UDEV_RULES = """\
+HOTPLUG_UDEV_RULES_TEMPLATE = """\
# Installed by cloud-init due to network hotplug userdata
ACTION!="add|remove", GOTO="cloudinit_end"
LABEL="cloudinit_hook"
-SUBSYSTEM=="net", RUN+="/usr/lib/cloud-init/hook-hotplug"
+SUBSYSTEM=="net", RUN+="{libexecdir}/hook-hotplug"
LABEL="cloudinit_end"
"""
@@ -129,8 +129,12 @@ def handle(_name, cfg, cloud, log, _args):
log.debug("Skipping hotplug install, udevadm not found")
return
+ # This may need to turn into a distro property at some point
+ libexecdir = "/usr/libexec/cloud-init"
+ if not os.path.exists(libexecdir):
+ libexecdir = "/usr/lib/cloud-init"
util.write_file(
filename=HOTPLUG_UDEV_PATH,
- content=HOTPLUG_UDEV_RULES,
+ content=HOTPLUG_UDEV_RULES_TEMPLATE.format(libexecdir=libexecdir),
)
subp.subp(["udevadm", "control", "--reload-rules"])
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py
index d61d280d..f2f2343c 100644
--- a/cloudinit/sources/__init__.py
+++ b/cloudinit/sources/__init__.py
@@ -196,6 +196,7 @@ class DataSource(CloudInitPickleMixin, metaclass=abc.ABCMeta):
EventType.BOOT_NEW_INSTANCE,
EventType.BOOT,
EventType.BOOT_LEGACY,
+ EventType.HOTPLUG,
}}
default_update_events = {EventScope.NETWORK: {
EventType.BOOT_NEW_INSTANCE,