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