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 EB60561212 for ; Fri, 4 Sep 2020 16:58:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DBFA1223D5 for ; Fri, 4 Sep 2020 16:58:42 +0200 (CEST) Received: from mx.giftfish.de (mx.giftfish.de [176.9.239.230]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 48227223BF for ; Fri, 4 Sep 2020 16:58:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=giftfish.de; s=dkim; t=1599231512; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type; bh=YYxSP8SZ3Lw5NBVQUgftrW0Z+CdUA0VGNWU7ZmELuxI=; b=RvnlMTR0Bbs5VABTNnWukym7Ls3VpcKsT1A/MfUrAfqcbE18t0y7VCxhlSj0JtuGl9waoZ q26LR76+Mm+hc3aseJ+xOCTreG9ntglWEigM03TjXLIzsYuIYZsIswooyp6ivjUgRVaalx WJY8tuiJLaHYEpruAzZeK3PjfXIYpNvDt2t/bOrooyE4FUORWYnAYXsRzdkzPnvAiRWuU9 xDPQ/F9YrsaoO6XRLdapw6gbzwgeV23njCT7jcmvbquTBLFZ2CazMynk2gusoyG9/lP2WO o0jrvg5p6S9wYM5kb7e5ZR0ulFK5CBV9gpDrBKuC2/HFDRG3Y6T7MbC9naX8Xg== Received: by mx.giftfish.de (OpenSMTPD) with ESMTP id fc7e314d for ; Fri, 4 Sep 2020 16:58:32 +0200 (CEST) Received: by mx.giftfish.de (kopano-spooler) with MAPI; Fri, 4 Sep 2020 16:58:32 +0200 From: "proxmox" To: "Proxmox VE development discussion" Date: Fri, 4 Sep 2020 14:58:32 +0000 Mime-Version: 1.0 X-Priority: 3 (Normal) Sender: "Marius Schellenberger" Message-Id: X-SPAM-LEVEL: Spam detection results: 0 AWL -0.100 Adjusted score from AWL reputation of From: address DKIM_INVALID 0.1 DKIM or DK signature exists, but is not valid DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid HTML_MESSAGE 0.001 HTML included in message KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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. [proxmox.com, qemu.pm, giftfish.de, cloudinit.pm, qemuserver.pm] Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.29 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, 04 Sep 2020 14:58:43 -0000 No actually this was a misstake. I tought my old patch was stuck in approval and got deleted. These patches can be ignored. -----Urspr=C3=BCngliche Nachricht----- Von: Mira Limbeck=C2=A0 Gesendet: Freitag 28 August 2020 17:46 An: pve-devel@lists.proxmox.com Betreff: Re: [pve-devel] [PATCH] api: cloud-init support for mtu and user= data Thank you for the patch. Seems to be the exactly the same as the one you sent some time ago:=20 https://lists.proxmox.com/pipermail/pve-devel/2020-July/044241.html Was this intentional=3F 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 =3D { > cipassword =3D> 1, > citype =3D> 1, > ciuser =3D> 1, > + ciuserdata =3D> 1, > nameserver =3D> 1, > searchdomain =3D> 1, > sshkeys =3D> 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 =3D { > description =3D> 'cloud-init: Specify custom files to replace = the automatically generated ones at start.', > format =3D> 'pve-qm-cicustom', > }, > + ciuserdata =3D> { > + optional =3D> 1, > + type =3D> 'string', > + format =3D> 'urlencoded', > + description =3D> 'cloud-init: Specify custom user-data as urle= ncoded base64 string to replace the automatically generated one at start.= When set, the following options have no effect: `ciuser`, `cipassword`, = `sshkeys`', > + }, > searchdomain =3D> { > optional =3D> 1, > type =3D> 'string', > @@ -932,6 +938,12 @@ my $ipconfig_fmt =3D { > optional =3D> 1, > requires =3D> 'ip6', > }, > + mtu =3D> { > + type =3D> 'string', > + format_description =3D> 'MTU', > + description =3D> 'MTU value for interface.', > + optional =3D> 1, > + }, > }; > PVE::JSONSchema::register_format('pve-qm-ipconfig', $ipconfig_fmt); > my $ipconfigdesc =3D { > @@ -1701,7 +1713,7 @@ sub parse_net { > return $res; > } > =20 > -# ipconfigX ip=3Dcidr,gw=3Dip,ip6=3Dcidr,gw6=3Dip > +# ipconfigX ip=3Dcidr,gw=3Dip,ip6=3Dcidr,gw6=3Dip,mtu=3Dmtu > sub parse_ipconfig { > my ($data) =3D @_; > =20 > @@ -1711,6 +1723,10 @@ sub parse_ipconfig { > return undef; > } > =20 > + 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); > =20 > 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) =3D @_; > =20 > + my $userdata =3D $conf->{ciuserdata}; > + if (defined($userdata) && $userdata ne "") { > + return decode_base64(uri_unescape($userdata)); > + } > + > my ($hostname, $fqdn) =3D get_hostname_fqdn($conf, $vmid); > =20 > my $content =3D "#cloud-config\n"; > @@ -176,7 +182,9 @@ sub configdrive2_network { > (my $id =3D $iface) =3D=CB=9C s/=CB=86net//; > next if !$conf->{"ipconfig$id"}; > my $net =3D PVE::QemuServer::parse_ipconfig($conf->{"ipconfig= $id"}); > + next if !defined($net); > $id =3D "eth$id"; > + my $mtu =3D $net->{mtu}; > =20 > $content .=3D"auto $id\n"; > if ($net->{ip}) { > @@ -189,6 +197,9 @@ sub configdrive2_network { > $content .=3D " netmask $mask\n"; > $content .=3D " gateway $net->{gw}\n" if $net->{g= w}; > } > + if (defined($mtu) && $mtu ne "") { > + $content .=3D " mtu $mtu\n"; > + } > } > if ($net->{ip6}) { > if ($net->{ip6} =3D=CB=9C /=CB=86(auto|dhcp)$/) { > @@ -200,6 +211,9 @@ sub configdrive2_network { > $content .=3D " netmask $mask\n"; > $content .=3D " gateway $net->{gw6}\n" if $net->{= gw6}; > } > + if (defined($mtu) && $mtu ne "") { > + $content .=3D " mtu $mtu\n"; > + } > } > } > =20 > @@ -261,6 +275,7 @@ sub nocloud_network_v2 { > =20 > my $net =3D PVE::QemuServer::parse_net($conf->{$iface}); > my $ipconfig =3D PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$= id"}); > + next if !defined($ipconfig); > =20 > my $mac =3D $net->{macaddr} > or die "network interface '$iface' has no mac address\n"; = > @@ -295,6 +310,10 @@ sub nocloud_network_v2 { > if (defined(my $gw =3D $ipconfig->{gw6})) { > $content .=3D "${i}gateway6: '$gw'\n"; > } > + my $mtu =3D $ipconfig->{mtu}; > + if (defined($mtu) && $mtu ne "") { > + $content .=3D "${i}mtu: $mtu\n"; > + } > =20 > next if $dns_done; > $dns_done =3D 1; > @@ -332,14 +351,22 @@ sub nocloud_network { > =20 > my $net =3D PVE::QemuServer::parse_net($conf->{$iface}); > my $ipconfig =3D PVE::QemuServer::parse_ipconfig($conf->{"ipconfig$= id"}); > + next if !defined($ipconfig); > =20 > my $mac =3D lc($net->{macaddr}) > or die "network interface '$iface' has no mac address\n"; > =20 > + my $mtu =3D $ipconfig->{mtu}; > + > $content .=3D "${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 .=3D "${i} mtu: $mtu\n"; > + } > + > + $content .=3D "${i} subnets:\n"; > $i .=3D ' '; > if (defined(my $ip =3D $ipconfig->{ip})) { > if ($ip eq 'dhcp') { _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel