From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 353DA6D0D2 for ; Thu, 12 Aug 2021 21:18:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 18AB526A0D for ; Thu, 12 Aug 2021 21:18:07 +0200 (CEST) Received: from mail.herold.me (mail.herold.me [90.187.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 60E0B269F5 for ; Thu, 12 Aug 2021 21:18:02 +0200 (CEST) X-Virus-Scanned: Yes From: Constantin Herold DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=herold.me; s=mail; t=1628795879; bh=5wA+NtgMrCrSy1ZqQiysDJmmUgqM3IeiDNFX4eHUiTs=; h=From:To:Cc:Subject; b=C1lbzY2DUZ8Zv5ytdHAyerpLf4mNrehfcDhVx6uN8vazM8ex+BRVjJ5TCMdQbuQiA 7Pol7RzOovMlmDma+epi6+UYg5tCR3v38zmP6sbwMxSSDUJ+9tA5FDvk2+AlTYxPWB Z5D2JdtJDzx+1M7Lf6C7vwOO5YTymnU2u8zaF+3A= To: pve-devel@lists.proxmox.com Date: Thu, 12 Aug 2021 21:17:49 +0200 Message-Id: <20210812191749.2055-1-proxmox8914@herold.me> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain KAM_INFOUSMEBIZ 0.75 Prevalent use of .info|.us|.me|.me.uk|.biz|xyz|id|rocks|life domains in spam/malware SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLACK 3 Contains an URL listed in the URIBL blacklist [herold.me] Subject: [pve-devel] [PATCH qemu-server] fix #2429: allow to specify cloud-init vendor snippet via cicustom X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Aug 2021 19:18:37 -0000 Signed-off-by: Constantin Herold --- PVE/QemuServer.pm | 8 ++++++++ PVE/QemuServer/Cloudinit.pm | 18 +++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index cc73af8..90a4496 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -713,6 +713,14 @@ my $cicustom_fmt = { format => 'pve-volume-id', format_description => 'volume', }, + vendor => { + type => 'string', + optional => 1, + description => 'Specify a custom file containing all vendor data passed to the VM via' + .' cloud-init.', + format => 'pve-volume-id', + format_description => 'volume', + }, }; PVE::JSONSchema::register_format('pve-qm-cicustom', $cicustom_fmt); diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm index a5474d3..ab5d358 100644 --- a/PVE/QemuServer/Cloudinit.pm +++ b/PVE/QemuServer/Cloudinit.pm @@ -227,7 +227,7 @@ EOF sub generate_configdrive2 { my ($conf, $vmid, $drive, $volname, $storeid) = @_; - my ($user_data, $network_data, $meta_data) = get_custom_cloudinit_files($conf); + my ($user_data, $network_data, $meta_data, $vendor_data) = get_custom_cloudinit_files($conf); $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data); $network_data = configdrive2_network($conf) if !defined($network_data); @@ -237,7 +237,8 @@ sub generate_configdrive2 { my $files = { '/openstack/latest/user_data' => $user_data, '/openstack/content/0000' => $network_data, - '/openstack/latest/meta_data.json' => $meta_data + '/openstack/latest/meta_data.json' => $meta_data, + '/openstack/latest/vendor_data.json' => $vendor_data }; commit_cloudinit_disk($conf, $vmid, $drive, $volname, $storeid, $files, 'config-2'); } @@ -493,7 +494,7 @@ sub nocloud_gen_metadata { sub generate_nocloud { my ($conf, $vmid, $drive, $volname, $storeid) = @_; - my ($user_data, $network_data, $meta_data) = get_custom_cloudinit_files($conf); + my ($user_data, $network_data, $meta_data, $vendor_data) = get_custom_cloudinit_files($conf); $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data); $network_data = nocloud_network($conf) if !defined($network_data); @@ -504,7 +505,8 @@ sub generate_nocloud { my $files = { '/user-data' => $user_data, '/network-config' => $network_data, - '/meta-data' => $meta_data + '/meta-data' => $meta_data, + '/vendor-data' => $vendor_data }; commit_cloudinit_disk($conf, $vmid, $drive, $volname, $storeid, $files, 'cidata'); } @@ -518,6 +520,7 @@ sub get_custom_cloudinit_files { my $network_volid = $files->{network}; my $user_volid = $files->{user}; my $meta_volid = $files->{meta}; + my $vendor_volid = $files->{vendor}; my $storage_conf = PVE::Storage::config(); @@ -536,7 +539,12 @@ sub get_custom_cloudinit_files { $meta_data = read_cloudinit_snippets_file($storage_conf, $meta_volid); } - return ($user_data, $network_data, $meta_data); + my $vendor_data; + if ($vendor_volid) { + $vendor_data = read_cloudinit_snippets_file($storage_conf, $vendor_volid); + } + + return ($user_data, $network_data, $meta_data, $vendor_data); } sub read_cloudinit_snippets_file { -- 2.23.0