From nobody Thu Nov 07 08:10:12 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XkZW83Gl4z5cXvD; Thu, 07 Nov 2024 08:10:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XkZW82jSrz466x; Thu, 7 Nov 2024 08:10:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730967012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PYnINq8LZ7qc1H5rRuDUCRyYSD2DYkfMsgXtZCF5O74=; b=BaBvSy1s+hCF3/euAlDQvTRgNdrlTeTipSFa1iiFkRaDmJS7WLcXzHF6vH+91mhoeQ4ZBL tGzIL5OUmq6jr3ths8Yv7aJk8X/Zrfpr209J1ZgXPhQbNDjciMmGP1Cz7eKBKejFbwPMXh AtdU8tQvnWG6sv3h2DanROJbUz715vbkW7eX2/Yy8LaAUhp0cJVeKNLVSyW4/3y0zcMHBt Cdq6VsmjTjuRA5o+uqQBY7lgXhrx/HmoioN63TF1xd7Vgr5eKMEIiUNoTtW1Ig261RlpTD Qm4zW9nF2MPIzPlGTIEDEFdXq1VmlKmr1Rfptxo2I+VUWQjo2jMv0R6Q4FYHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730967012; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PYnINq8LZ7qc1H5rRuDUCRyYSD2DYkfMsgXtZCF5O74=; b=cNQq7bNDVuSJp+qwZRF6tXwql5h5jELlSxx2CuO4lH6s+6tABsRx4uJF/vGhYRaPcIAYhe 1277kndaI4K+DdTE2gOCaNU7w5ScdlYrLFMzG1Mh7BE3op180bXgA+kc1kj1NnA67hA0k0 LWmpkDJiXGiCssD1z4TYXzgdOrxUS0+sqQzZU3ylmkWckTFtm7XsCOtkpKlkAYosSTPYGq CmZ7hNLMsews88wgwh7lAHsmTl+XUPD7/iD5fpzLzGNhmLtnJf9AyOK8W7JJKprbLTSBzu hWMFsBJQGBYiP4eyWJ5MiGbhzUzPlXbpC2v5gfwYHcjab5iiARCqyxnF5BKsdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730967012; a=rsa-sha256; cv=none; b=ckiP2VAax5guEbUkw6sz14d5TcC9KB96RYIieqfBkEhAxbyTkbGnDNYE+neG638UuSgBP0 KzDaEGLi1dEt0v/0CyUphiQySjrtayObn1GhCE9XyyE4ZpOSkhmEYBINzVAhqpyAJuUG54 wVWaZ6u3WbY7jJfy43VGGV+Ox1faGJUAH7lMWvFrH6lf3gYQ1s2fD1XYeiPkylpFGH3yP+ i6R8nr3Te5yPHEdWgY/z26Yk2KAnwv/Xf9nhlTvlAaGbfDspx3HwWJz96d6usqTHx5543O 1O1DXej7r2S3OG/IOH8IUhl4iYv1/mrFVSc4kAJNodY2Zlsd31atXogvak7EBw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XkZW82Jv5zdN8; Thu, 7 Nov 2024 08:10:12 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A78ACB5027229; Thu, 7 Nov 2024 08:10:12 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A78ACXj027217; Thu, 7 Nov 2024 08:10:12 GMT (envelope-from git) Date: Thu, 7 Nov 2024 08:10:12 GMT Message-Id: <202411070810.4A78ACXj027217@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Baptiste Daroussin Subject: git: ea310d18b222 - releng/14.2 - nuageinit: add support for OpenStack network config List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-branches@freebsd.org Sender: owner-dev-commits-src-branches@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: bapt X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.2 X-Git-Reftype: branch X-Git-Commit: ea310d18b222047caf6cb07f6bdc37020dc672b6 Auto-Submitted: auto-generated The branch releng/14.2 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=ea310d18b222047caf6cb07f6bdc37020dc672b6 commit ea310d18b222047caf6cb07f6bdc37020dc672b6 Author: Baptiste Daroussin AuthorDate: 2024-10-29 13:17:39 +0000 Commit: Baptiste Daroussin CommitDate: 2024-11-07 08:09:54 +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. Approved by: re (cperviva) MFC after: 3 weeks Sponsored by: OVHCloud (cherry picked from commit 2775b9b0bcc278dd4183b57784953c26a3fcdc89) (cherry picked from commit 6c682f5c3860a49cd0440599fffe1106c00ff830) --- 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