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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 3DEE36901F for ; Fri, 28 Aug 2020 17:46:36 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 34FB6238DF for ; Fri, 28 Aug 2020 17:46:06 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 9B5BA238D1 for ; Fri, 28 Aug 2020 17:46:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 71AE943FC7 for ; Fri, 28 Aug 2020 17:46:02 +0200 (CEST) To: pve-devel@lists.proxmox.com References: <20200811190203.10151-1-proxmox@giftfish.de> <20200811190203.10151-2-proxmox@giftfish.de> From: Mira Limbeck Message-ID: <9c4d8603-e54f-1b35-b4e5-267e29fa3f19@proxmox.com> Date: Fri, 28 Aug 2020 17:46:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20200811190203.10151-2-proxmox@giftfish.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 1.492 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -1.782 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [cloudinit.pm, qemuserver.pm, qemu.pm, proxmox.com] Subject: Re: [pve-devel] [PATCH] api: cloud-init support for mtu and userdata 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: Fri, 28 Aug 2020 15:46:36 -0000 Thank you for the patch. Seems to be the exactly the same as the one you sent some time ago: https://lists.proxmox.com/pipermail/pve-devel/2020-July/044241.html Was this intentional? On 8/11/20 9:02 PM, Marius Schellenberger wrote: > Extended the PVE API to configure cloud-init userdata and network > interface MTU. > > Signed-off-by: Marius Schellenberger > --- > PVE/API2/Qemu.pm | 1 + > PVE/QemuServer.pm | 18 +++++++++++++++++- > PVE/QemuServer/Cloudinit.pm | 31 +++++++++++++++++++++++++++++-- > 3 files changed, 47 insertions(+), 3 deletions(-) > > diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm > index 8da616a..5d149a5 100644 > --- a/PVE/API2/Qemu.pm > +++ b/PVE/API2/Qemu.pm > @@ -324,6 +324,7 @@ my $cloudinitoptions = { > cipassword => 1, > citype => 1, > ciuser => 1, > + ciuserdata => 1, > nameserver => 1, > searchdomain => 1, > sshkeys => 1, > diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm > index a9c0dac..974a070 100644 > --- a/PVE/QemuServer.pm > +++ b/PVE/QemuServer.pm > @@ -727,6 +727,12 @@ my $confdesc_cloudinit = { > description => 'cloud-init: Specify custom files to replace the automatically generated ones at start.', > format => 'pve-qm-cicustom', > }, > + ciuserdata => { > + optional => 1, > + type => 'string', > + format => 'urlencoded', > + description => 'cloud-init: Specify custom user-data as urlencoded base64 string to replace the automatically generated one at start. When set, the following options have no effect: `ciuser`, `cipassword`, `sshkeys`', > + }, > searchdomain => { > optional => 1, > type => 'string', > @@ -932,6 +938,12 @@ my $ipconfig_fmt = { > optional => 1, > requires => 'ip6', > }, > + mtu => { > + type => 'string', > + format_description => 'MTU', > + description => 'MTU value for interface.', > + optional => 1, > + }, > }; > PVE::JSONSchema::register_format('pve-qm-ipconfig', $ipconfig_fmt); > my $ipconfigdesc = { > @@ -1701,7 +1713,7 @@ sub parse_net { > return $res; > } > > -# ipconfigX ip=cidr,gw=ip,ip6=cidr,gw6=ip > +# ipconfigX ip=cidr,gw=ip,ip6=cidr,gw6=ip,mtu=mtu > sub parse_ipconfig { > my ($data) = @_; > > @@ -1711,6 +1723,10 @@ sub parse_ipconfig { > return undef; > } > > + if ($res->{mtu} && !$res->{ip} && !$res->{ip6}) { > + warn 'mtu specified without specifying an IP or IPv6 address'; > + return undef; > + } > if ($res->{gw} && !$res->{ip}) { > warn 'gateway specified without specifying an IP address'; > return undef; > diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm > index 439de99..a47e0ce 100644 > --- a/PVE/QemuServer/Cloudinit.pm > +++ b/PVE/QemuServer/Cloudinit.pm > @@ -6,6 +6,7 @@ use warnings; > use File::Path; > use Digest::SHA; > use URI::Escape; > +use MIME::Base64 qw(decode_base64); > > use PVE::Tools qw(run_command file_set_contents); > use PVE::Storage; > @@ -111,6 +112,11 @@ sub get_dns_conf { > sub cloudinit_userdata { > my ($conf, $vmid) = @_; > > + my $userdata = $conf->{ciuserdata}; > + if (defined($userdata) && $userdata ne "") { > + return decode_base64(uri_unescape($userdata)); > + } > + > my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid); > > my $content = "#cloud-config\n"; > @@ -176,7 +182,9 @@ sub configdrive2_network { > (my $id = $iface) =~ s/^net//; > next if !$conf->{"ipconfig$id"}; > my $net = PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$id"}); > + next if !defined($net); > $id = "eth$id"; > + my $mtu = $net->{mtu}; > > $content .="auto $id\n"; > if ($net->{ip}) { > @@ -189,6 +197,9 @@ sub configdrive2_network { > $content .= " netmask $mask\n"; > $content .= " gateway $net->{gw}\n" if $net->{gw}; > } > + if (defined($mtu) && $mtu ne "") { > + $content .= " mtu $mtu\n"; > + } > } > if ($net->{ip6}) { > if ($net->{ip6} =~ /^(auto|dhcp)$/) { > @@ -200,6 +211,9 @@ sub configdrive2_network { > $content .= " netmask $mask\n"; > $content .= " gateway $net->{gw6}\n" if $net->{gw6}; > } > + if (defined($mtu) && $mtu ne "") { > + $content .= " mtu $mtu\n"; > + } > } > } > > @@ -261,6 +275,7 @@ sub nocloud_network_v2 { > > my $net = PVE::QemuServer::parse_net($conf->{$iface}); > my $ipconfig = PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$id"}); > + next if !defined($ipconfig); > > my $mac = $net->{macaddr} > or die "network interface '$iface' has no mac address\n"; > @@ -295,6 +310,10 @@ sub nocloud_network_v2 { > if (defined(my $gw = $ipconfig->{gw6})) { > $content .= "${i}gateway6: '$gw'\n"; > } > + my $mtu = $ipconfig->{mtu}; > + if (defined($mtu) && $mtu ne "") { > + $content .= "${i}mtu: $mtu\n"; > + } > > next if $dns_done; > $dns_done = 1; > @@ -332,14 +351,22 @@ sub nocloud_network { > > my $net = PVE::QemuServer::parse_net($conf->{$iface}); > my $ipconfig = PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$id"}); > + next if !defined($ipconfig); > > my $mac = lc($net->{macaddr}) > or die "network interface '$iface' has no mac address\n"; > > + my $mtu = $ipconfig->{mtu}; > + > $content .= "${i}- type: physical\n" > . "${i} name: eth$id\n" > - . "${i} mac_address: '$mac'\n" > - . "${i} subnets:\n"; > + . "${i} mac_address: '$mac'\n"; > + > + if (defined($mtu) && $mtu ne "") { > + $content .= "${i} mtu: $mtu\n"; > + } > + > + $content .= "${i} subnets:\n"; > $i .= ' '; > if (defined(my $ip = $ipconfig->{ip})) { > if ($ip eq 'dhcp') {