diff options
author | James Falcon <therealfalcon@gmail.com> | 2021-07-19 14:13:21 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-19 14:13:21 -0500 |
commit | 184c836a16e9954a2cba11ae21f07923077ec904 (patch) | |
tree | 6289d70e4f833d300a25136dde6a56fcd1b0a0dc /tools | |
parent | eacb0353803263934aa2ac827c37e461c87cb107 (diff) | |
download | vyos-cloud-init-184c836a16e9954a2cba11ae21f07923077ec904.tar.gz vyos-cloud-init-184c836a16e9954a2cba11ae21f07923077ec904.zip |
Initial hotplug support (#936)
Adds a udev script which will invoke a hotplug hook script on all net
add events. The script will write some udev arguments to a systemd FIFO
socket (to ensure we have only instance of cloud-init running at a
time), which is then read by a new service that calls a new 'cloud-init
devel hotplug-hook' command to handle the new event.
This hotplug-hook command will:
- Fetch the pickled datsource
- Verify that the hotplug event is supported/enabled
- Update the metadata for the datasource
- Ensure the hotplugged device exists within the datasource
- Apply the config change on the datasource metadata
- Bring up the new interface (or apply global network configuration)
- Save the updated metadata back to the pickle cache
Also scattered in some unrelated typing where helpful
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/hook-hotplug | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/hook-hotplug b/tools/hook-hotplug new file mode 100755 index 00000000..34e95929 --- /dev/null +++ b/tools/hook-hotplug @@ -0,0 +1,21 @@ +#!/bin/bash +# This file is part of cloud-init. See LICENSE file for license information. + +# This script checks if cloud-init has hotplug hooked and if +# cloud-init has finished; if so invoke cloud-init hotplug-hook + +is_finished() { + [ -e /run/cloud-init/result.json ] +} + +if is_finished; then + # open cloud-init's hotplug-hook fifo rw + exec 3<>/run/cloud-init/hook-hotplug-cmd + env_params=( + --devpath="${DEVPATH}" + --subsystem="${SUBSYSTEM}" + --udevaction="${ACTION}" + ) + # write params to cloud-init's hotplug-hook fifo + echo "${env_params[@]}" >&3 +fi |