Commit 204355df authored by Dietmar Maurer's avatar Dietmar Maurer

allow to filter specific resource types

parent 3a1d95cc
......@@ -112,7 +112,13 @@ __PACKAGE__->register_method({
permissions => { user => 'all' },
parameters => {
additionalProperties => 0,
properties => {},
properties => {
type => {
type => 'string',
optional => 1,
enum => ['vm', 'storage', 'node'],
},
},
},
returns => {
type => 'array',
......@@ -140,9 +146,11 @@ __PACKAGE__->register_method({
# we try to generate 'numbers' by using "$X + 0"
if (!$param->{type} || $param->{type} eq 'vm') {
foreach my $vmid (keys %$idlist) {
my $data = $idlist->{$vmid};
next if !$rpcenv->check($user, "/vms/$vmid", [ 'VM.Audit' ]);
my $entry = {
......@@ -167,7 +175,9 @@ __PACKAGE__->register_method({
push @$res, $entry;
}
}
if (!$param->{type} || $param->{type} eq 'node') {
foreach my $node (@$nodelist) {
my $entry = {
id => "node/$node",
......@@ -189,9 +199,11 @@ __PACKAGE__->register_method({
$entry->{maxdisk} = ($d->[10] || 0) + 0;
}
push @$res, $entry;
}
}
if (!$param->{type} || $param->{type} eq 'storage') {
my $cfg = PVE::Storage::config();
my @sids = PVE::Storage::storage_ids ($cfg);
......@@ -215,7 +227,7 @@ __PACKAGE__->register_method({
}
push @$res, $entry;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment