From 399932c682182ffeeb95f67c5d99aee587c57d0e Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 26 Jan 2012 13:02:07 +0100 Subject: [PATCH] return array instead of hash --- PVE/API2/Pool.pm | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/PVE/API2/Pool.pm b/PVE/API2/Pool.pm index f224777..c4b1e20 100644 --- a/PVE/API2/Pool.pm +++ b/PVE/API2/Pool.pm @@ -214,7 +214,19 @@ __PACKAGE__->register_method ({ poolid => {type => 'string', format => 'pve-poolid' }, }, }, - returns => {}, + returns => { + type => 'array', + items => { + type => "object", + additionalProperties => 0, + properties => { + type => { type => 'string', enum => ['vm', 'storage'] }, + id => { type => 'string' }, + vmid => { type => 'integer', optional => 1 }, + storage => { type => 'string', optional => 1 }, + }, + }, + }, code => sub { my ($param) = @_; @@ -227,7 +239,25 @@ __PACKAGE__->register_method ({ die "pool '$pool' does not exist\n" if !$data; - return &$extract_pool_data($data, 1); + my $res = []; + + foreach my $vmid (keys %{$data->{vms}}) { + push @$res, { + id => "vm/$vmid", + vmid => $vmid + 0, + type => 'vm', + }; + } + + foreach my $storage (keys %{$data->{storage}}) { + push @$res, { + id => "storage/$storage", + storage => $storage, + type => 'storage', + }; + } + + return $res; }}); -- 2.39.2