]> git.proxmox.com Git - qemu-server.git/blob - PVE/API2/Qemu/OVF.pm
schema: fix description of migrate_downtime parameter
[qemu-server.git] / PVE / API2 / Qemu / OVF.pm
1 package PVE::API2::Qemu::OVF;
2
3 use strict;
4 use warnings;
5
6 use PVE::JSONSchema qw(get_standard_option);
7 use PVE::QemuServer::OVF;
8 use PVE::RESTHandler;
9
10 use base qw(PVE::RESTHandler);
11
12 __PACKAGE__->register_method ({
13 name => 'readovf',
14 path => '',
15 method => 'GET',
16 proxyto => 'node',
17 description => "Read an .ovf manifest.",
18 protected => 1,
19 parameters => {
20 additionalProperties => 0,
21 properties => {
22 node => get_standard_option('pve-node'),
23 manifest => {
24 description => "Path to .ovf manifest.",
25 type => 'string',
26 },
27 },
28 },
29 returns => {
30 type => 'object',
31 additionalProperties => 1,
32 properties => PVE::QemuServer::json_ovf_properties(),
33 description => "VM config according to .ovf manifest.",
34 },
35 code => sub {
36 my ($param) = @_;
37
38 my $manifest = $param->{manifest};
39 die "check for file $manifest failed - $!\n" if !-f $manifest;
40
41 my $parsed = PVE::QemuServer::OVF::parse_ovf($manifest);
42 my $result;
43 $result->{cores} = $parsed->{qm}->{cores};
44 $result->{name} = $parsed->{qm}->{name};
45 $result->{memory} = $parsed->{qm}->{memory};
46 my $disks = $parsed->{disks};
47 for my $disk (@$disks) {
48 $result->{$disk->{disk_address}} = $disk->{backing_file};
49 }
50 return $result;
51 }});
52
53 1;