]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/list.pm
1 package PVE
::APIClient
::Commands
::list
;
7 use PVE
::JSONSchema
qw(get_standard_option);
9 use base
qw(PVE::CLIHandler);
11 __PACKAGE__-
>register_method ({
15 description
=> "List containers.",
17 additionalProperties
=> 0,
19 remote
=> get_standard_option
('pveclient-remote-name'),
22 description
=> 'Output format',
23 enum
=> [ 'table', 'json' ],
29 returns
=> { type
=> 'null'},
33 my $config = PVE
::APIClient
::Config-
>load();
34 my $conn = PVE
::APIClient
::Config-
>remote_conn($config, $param->{remote
});
35 my $resources = $conn->get('api2/json/cluster/resources', { type
=> 'vm' });
37 if (!defined($param->{format
}) or $param->{format
} eq 'table') {
38 my $headers = ['Node', 'VMID', 'Type', 'Name', 'Status'];
40 for my $el (@$resources) {
41 push(@$data, [$el->{node
}, $el->{vmid
}, $el->{type
}, $el->{name
}, $el->{status
}]);
44 printf("%10s %10s %10s %10s %10s\n", @$headers);
45 for my $row (@$data) {
46 printf("%10s %10s %10s %10s %10s\n", @$row);
49 print JSON
::to_json
($resources, {utf8
=> 1, pretty
=> 1});
56 our $cmddef = [ __PACKAGE__
, 'list', ['remote']];