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 C69346B07A for ; Mon, 8 Mar 2021 13:39:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B884B1E5E5 for ; Mon, 8 Mar 2021 13:39:24 +0100 (CET) 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 7DA7D1E5D9 for ; Mon, 8 Mar 2021 13:39:23 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 50C1941E01 for ; Mon, 8 Mar 2021 13:39:23 +0100 (CET) Date: Mon, 08 Mar 2021 13:39:16 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Dominic =?iso-8859-1?b?SuRnZXI=?= , Proxmox VE development discussion References: <20210205100442.28163-1-d.jaeger@proxmox.com> <20210205100442.28163-2-d.jaeger@proxmox.com> <1612950071.k22hsf3al3.astroid@nora.none> <20210308113849.GA78471@mala> In-Reply-To: <20210308113849.GA78471@mala> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1615206718.02ofggnz5w.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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 Subject: Re: [pve-devel] [PATCH v4 manager] gui: Add import wizard for disk & VM 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: Mon, 08 Mar 2021 12:39:54 -0000 On March 8, 2021 12:38 pm, Dominic J=C3=A4ger wrote: > On Wed, Feb 10, 2021 at 10:49:41AM +0100, Fabian Gr=C3=BCnbichler wrote: >> >=20 >> > diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm >> > index 8172231e..9bf75ab7 100644 >> > --- a/PVE/API2/Nodes.pm >> > +++ b/PVE/API2/Nodes.pm >> > @@ -27,6 +27,7 @@ use PVE::HA::Env::PVE2; >> > use PVE::HA::Config; >> > use PVE::QemuConfig; >> > use PVE::QemuServer; >> > +use PVE::QemuServer::OVF; >> > use PVE::API2::Subscription; >> > use PVE::API2::Services; >> > use PVE::API2::Network; >> > @@ -224,6 +225,7 @@ __PACKAGE__->register_method ({ >> > { name =3D> 'subscription' }, >> > { name =3D> 'report' }, >> > { name =3D> 'tasks' }, >> > + { name =3D> 'readovf' }, >> > { name =3D> 'rrd' }, # fixme: remove? >> > { name =3D> 'rrddata' },# fixme: remove? >> > { name =3D> 'replication' }, >> > @@ -2173,6 +2175,44 @@ __PACKAGE__->register_method ({ >> > return undef; >> > }}); >>=20 >> this API endpoint belongs in qemu-server? >=20 >=20 > I am not sure. It looked to me like qemu-server implied > nodes//qemu//readovf > but I wanted to avoid and place it next to > nodes//status, nodes//rrd, ... > which are in this file? qemu-server also ships API paths besides /nodes//qemu/*, e.g.=20 PVE::API2::Qemu::CPU provides /nodes//cpu, so we might do a=20 /nodes//ovf (or something similar under /cluster, if it's not at=20 all node-dependent). >> > =20 >> > +__PACKAGE__->register_method ({ >> > + name =3D> 'readovf', >> > + path =3D> 'readovf', >> > + method =3D> 'GET', >> > + proxyto =3D> 'node', >> > + description =3D> "Read an .ovf manifest.", >> > + parameters =3D> { >> > + additionalProperties =3D> 0, >> > + properties =3D> { >> > + node =3D> get_standard_option('pve-node'), >> > + manifest =3D> { >> > + description =3D> ".ovf manifest", >> > + type =3D> 'string', >> > + }, >> > + }, >> > + }, >> > + returns =3D> { >> > + description =3D> "VM config according to .ovf manifest and digest of= manifest", >> > + type =3D> "object", >>=20 >> according to the code below, this has a defined schema? >=20 > Yes. Something like >=20 > returns =3D> { > type =3D> 'object', > additionalProperties =3D> 0, > properties =3D> { > name =3D> { > type =3D> 'string', > optional =3D> 1, > }, > cores =3D> { > type =3D> 'integer', > optional =3D> 1, > }, > memory =3D> { > type =3D> 'integer', > optional =3D> 1, > }, > ?? =3D> { > type =3D> 'string', > description =3D> 'path of a disk image', > }, > ?? =3D> { > type =3D> 'string', > description =3D> 'path of a disk image', > }, > .... > }, >=20 > but the only way I have found so far to return paths > scsi1 =3D> /some/image.img > sata3 =3D> /some/other.img >=20 > is PVE::QemuServer::json_config_properties( which allows much more than c= an be > read from the OVF at the moment. you can just have your own helper that uses the existing valid disk=20 names helper, takes the static part of the return schema and generates=20 the full return schema. >>=20 >> > + }, >> > + code =3D> sub { >> > + my ($param) =3D @_; >> > + >> > + my $manifest =3D $param->{manifest}; >> > + die "$manifest: non-existent or non-regular file\n" if (! -f $manife= st); >> > + >> > + my $parsed =3D PVE::QemuServer::OVF::parse_ovf($manifest, 0, 1); >> > + my $result; >> > + $result->{cores} =3D $parsed->{qm}->{cores}; >> > + $result->{name} =3D $parsed->{qm}->{name}; >> > + $result->{memory} =3D $parsed->{qm}->{memory}; >> > + my $disks =3D $parsed->{disks}; >> > + foreach my $disk (@$disks) { >> > + $result->{$disk->{disk_address}} =3D $disk->{backing_file}; >> > + } >> > + return $result; >> > +}}); >> > + >> > # bash completion helper >> > =20 >> > sub complete_templet_repo { >=20 =