Date: Tue, 29 Oct 2024 13:24:53 GMT From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 2775b9b0bcc2 - main - nuageinit: add support for OpenStack network config Message-ID: <202410291324.49TDOrqu017551@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=2775b9b0bcc278dd4183b57784953c26a3fcdc89 commit 2775b9b0bcc278dd4183b57784953c26a3fcdc89 Author: Baptiste Daroussin <bapt@FreeBSD.org> AuthorDate: 2024-10-29 13:17:39 +0000 Commit: Baptiste Daroussin <bapt@FreeBSD.org> CommitDate: 2024-10-29 13:23:47 +0000 nuageinit: add support for OpenStack network config Add naive support for openstack network config. if no config driver have been found, try to detect that we are running a VM on openstack via the smbios information, use the first iface available and temporary activate dhcp on it, to be able to fetch the necessary informations for cloudinit. While here make the rc script execute after devmatch, some ethernet device might be attached via devmatch and may be needed for cloudinit. Tested on OVHCloud Public Cloud. MFC after: 3 weeks Sponsored by: OVHCloud --- libexec/rc/rc.d/nuageinit | 45 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/libexec/rc/rc.d/nuageinit b/libexec/rc/rc.d/nuageinit index a44761ea1d9e..54e5b1fbec07 100755 --- a/libexec/rc/rc.d/nuageinit +++ b/libexec/rc/rc.d/nuageinit @@ -2,7 +2,7 @@ # # PROVIDE: nuageinit -# REQUIRE: mountcritlocal zfs +# REQUIRE: mountcritlocal zfs devmatch # BEFORE: NETWORKING # KEYWORD: firstboot @@ -14,6 +14,18 @@ start_cmd="nuageinit_start" stop_cmd=":" rcvar="nuageinit_enable" +fetch_openstack() +{ + cd /media/nuageinit/openstack/latest + for file in meta_data.json network_data.json user_data; do + fetch http://169.254.169.254/openstack/latest/$file || : + done + if [ -f user_data ]; then + chmod 755 user_data + fi + cd - +} + nuageinit_start() { local citype @@ -34,13 +46,28 @@ nuageinit_start() fi unset drive done - if [ -z "$drive" ]; then - # try to detect networked based instance - err 1 "Impossible to find a cloud init provider" + if [ -n "$drive" ]; then + mkdir -p /media/nuageinit + fs=$(fstyp $drive 2> /dev/null) + mount -t $fs $drive /media/nuageinit + else + product=$(kenv smbios.system.product) + case "$product" in + OpenStack*) + mkdir -p /media/nuageinit/openstack/latest + ifaces=$(ifconfig -l ether) + set -- $ifaces + dhclient -p /tmp/ephemeraldhcp.pid $1 + fetch_openstack + pkill -F /tmp/ephemeraldhcp.pid + citype=config-2 + ;; + *) + # try to detect networked based instance + err 1 "Impossible to find a cloud init provider" + ;; + esac fi - mkdir -p /media/nuageinit - fs=$(fstyp $drive 2> /dev/null) - mount -t $fs $drive /media/nuageinit # according to the specification, the content is either # in the openstack or ec2 directory case "$citype" in @@ -59,8 +86,10 @@ nuageinit_start() esac if [ -n "$drive" ]; then umount /media/nuageinit + rmdir /media/nuageinit + else + rm -rf /media/nuageinit fi - rmdir /media/nuageinit } load_rc_config $name
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202410291324.49TDOrqu017551>