From: "Dominic Jäger" <d.jaeger@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH v4 manager] gui: Add import wizard for disk & VM
Date: Mon, 8 Mar 2021 12:38:49 +0100 [thread overview]
Message-ID: <20210308113849.GA78471@mala> (raw)
In-Reply-To: <1612950071.k22hsf3al3.astroid@nora.none>
On Wed, Feb 10, 2021 at 10:49:41AM +0100, Fabian Grünbichler wrote:
> >
> > 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 => 'subscription' },
> > { name => 'report' },
> > { name => 'tasks' },
> > + { name => 'readovf' },
> > { name => 'rrd' }, # fixme: remove?
> > { name => 'rrddata' },# fixme: remove?
> > { name => 'replication' },
> > @@ -2173,6 +2175,44 @@ __PACKAGE__->register_method ({
> > return undef;
> > }});
>
> this API endpoint belongs in qemu-server?
I am not sure. It looked to me like qemu-server implied
nodes/<node>/qemu/<vmid>/readovf
but I wanted to avoid <vmid> and place it next to
nodes/<node>/status, nodes/<node>/rrd, ...
which are in this file?
> >
> > +__PACKAGE__->register_method ({
> > + name => 'readovf',
> > + path => 'readovf',
> > + method => 'GET',
> > + proxyto => 'node',
> > + description => "Read an .ovf manifest.",
> > + parameters => {
> > + additionalProperties => 0,
> > + properties => {
> > + node => get_standard_option('pve-node'),
> > + manifest => {
> > + description => ".ovf manifest",
> > + type => 'string',
> > + },
> > + },
> > + },
> > + returns => {
> > + description => "VM config according to .ovf manifest and digest of manifest",
> > + type => "object",
>
> according to the code below, this has a defined schema?
Yes. Something like
returns => {
type => 'object',
additionalProperties => 0,
properties => {
name => {
type => 'string',
optional => 1,
},
cores => {
type => 'integer',
optional => 1,
},
memory => {
type => 'integer',
optional => 1,
},
?? => {
type => 'string',
description => 'path of a disk image',
},
?? => {
type => 'string',
description => 'path of a disk image',
},
....
},
but the only way I have found so far to return paths
scsi1 => /some/image.img
sata3 => /some/other.img
is PVE::QemuServer::json_config_properties( which allows much more than can be
read from the OVF at the moment.
>
> > + },
> > + code => sub {
> > + my ($param) = @_;
> > +
> > + my $manifest = $param->{manifest};
> > + die "$manifest: non-existent or non-regular file\n" if (! -f $manifest);
> > +
> > + my $parsed = PVE::QemuServer::OVF::parse_ovf($manifest, 0, 1);
> > + my $result;
> > + $result->{cores} = $parsed->{qm}->{cores};
> > + $result->{name} = $parsed->{qm}->{name};
> > + $result->{memory} = $parsed->{qm}->{memory};
> > + my $disks = $parsed->{disks};
> > + foreach my $disk (@$disks) {
> > + $result->{$disk->{disk_address}} = $disk->{backing_file};
> > + }
> > + return $result;
> > +}});
> > +
> > # bash completion helper
> >
> > sub complete_templet_repo {
next prev parent reply other threads:[~2021-03-08 11:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-05 10:04 [pve-devel] [PATCH v4 qemu-server] Add API for disk & VM import Dominic Jäger
2021-02-05 10:04 ` [pve-devel] [PATCH v4 manager] gui: Add import wizard for disk & VM Dominic Jäger
2021-02-10 9:49 ` Fabian Grünbichler
2021-03-08 11:38 ` Dominic Jäger [this message]
2021-03-08 12:39 ` Fabian Grünbichler
2021-02-10 9:40 ` [pve-devel] [PATCH v4 qemu-server] Add API for disk & VM import Fabian Grünbichler
2021-02-11 10:32 ` Dominic Jäger
2021-02-12 9:03 ` Fabian Grünbichler
2021-02-12 11:13 ` Dominic Jäger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210308113849.GA78471@mala \
--to=d.jaeger@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox