From nobody Wed Nov 06 08:36:17 2024 X-Original-To: dev-commits-src-all@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 4Xjz7j2yR8z5cJc0; Wed, 06 Nov 2024 08:36:17 +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 4Xjz7j2Fkfz4TDl; Wed, 6 Nov 2024 08:36:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730882177; 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=KlpjzgPbIL3ZqC/jNmRhJ3i6sNVX7/1/gxauDj2FTs0=; b=u++/xlG84nejFZmR/l8ycf6bxrTIYhLemD0tJ93vYGrUQXsvW8Fj+ES8VGmxrE7gMnFFJ/ nZqpo6f0CIrKPDCsCkv0PDWhM/PeFZIqQc8tandd5m0EsAqqprdQeCZ1jlgWimLVVtESfr 8A7QGXIBMO2WJmcJcM9uwW1nEOKCKNHSEOf604XLamK3mD+UhpygEuQiebDIRutKHbJ1R/ yMOfYODOC6H5AnkXB4+evit0mKFO3ZtpuJvBFkYGHmYrJL1DDo5ykdFGM4pufypkLXddUc IbgCy4wy1be1NHT76Uttbjuvwn0Y8tvDEUpsCXk6zGDN1Gp2nC6+/64kWRQE4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730882177; 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=KlpjzgPbIL3ZqC/jNmRhJ3i6sNVX7/1/gxauDj2FTs0=; b=jYW8sjre1QpTr0NQRNpRevC1A2z/CMYwjacax/1MtcaA+mrJMJCAlK2nIxgXUTNcptWL7r FcepntG899NbQjjVnQUeK2VzGg85Gulwv1jhTPzTtReCrCLFGDAj8g0xdl7z/PQm5i/9s2 bTndyJe0nh2oaXsS6RBgCzpqC3BKG/rX4hcBAvV3BtD2oIiNqrzzTzuIwHML/Fjg7M0xmL wozBxUZ2vIGPbD5cjrzVTZo2lISiskYn7j5EfakqZ+TkoKMMygacYVazlJNV4saj3xVR0g J89KhsAMIVuCSbBId/cqPkwGLzA8LxGemDZOeUw3QJS5qpdyco3/fRBgavw3yw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730882177; a=rsa-sha256; cv=none; b=iLGZh025ftmCHawXFEyEwwRfidnH5hLTWxz0RlDxdvXEQxHf+8j+a4MCH3C2N51DmVX/ka Fiz2wt2ywwFA6zxsnD2bhWaoEf/6AWza3iFXd+Ad2CQViSd0sXyLyourVfNLDYoQ1f+1e0 7s58hO4ASeOg24gMu8t+z6a5lxnZjyZwMjhGkI7Th3QG5+HLNEn3AuCGC0Ws9K6f+cSkfN PSM6qNbKywHQVbhjc8LT9nSGJ+5Sw1+X9PpAXt8cymYFAGolBUh8cL2dLCOeI7YCN/I3aA yWd/QjpK3lBo5WfBcaaIXZwAkf7lY8LLWMrPO4XnEyNx37qk7jbXOkktigKObQ== 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 4Xjz7j1s39ztmV; Wed, 6 Nov 2024 08:36:17 +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 4A68aH4Z098397; Wed, 6 Nov 2024 08:36:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A68aHbY098394; Wed, 6 Nov 2024 08:36:17 GMT (envelope-from git) Date: Wed, 6 Nov 2024 08:36:17 GMT Message-Id: <202411060836.4A68aHbY098394@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: 6c682f5c3860 - stable/14 - nuageinit: add support for OpenStack network config List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 6c682f5c3860a49cd0440599fffe1106c00ff830 Auto-Submitted: auto-generated The branch stable/14 has been updated by bapt: URL: https://cgit.FreeBSD.org/src/commit/?id=6c682f5c3860a49cd0440599fffe1106c00ff830 commit 6c682f5c3860a49cd0440599fffe1106c00ff830 Author: Baptiste Daroussin AuthorDate: 2024-10-29 13:17:39 +0000 Commit: Baptiste Daroussin CommitDate: 2024-11-06 08:36:12 +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 (cherry picked from commit 2775b9b0bcc278dd4183b57784953c26a3fcdc89) --- 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