]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Commands/lxc.pm
1 package PVE
::APIClient
::Commands
::lxc
;
7 use PVE
::JSONSchema
qw(get_standard_option);
10 use base
qw(PVE::CLIHandler);
11 use PVE
::APIClient
::Config
;
13 my $load_remote_config = sub {
16 my $conf = PVE
::APIClient
::Config
::load_config
();
18 my $remote_conf = $conf->{"remote_$remote"} ||
19 die "no such remote '$remote'\n";
21 foreach my $opt (qw(hostname username password fingerprint)) {
22 die "missing option '$opt' (remote '$remote')" if !defined($remote_conf->{$opt});
28 my $get_remote_connection = sub {
31 my $conf = $load_remote_config->($remote);
33 return PVE
::APIClient
::LWP-
>new(
34 username
=> $conf->{username
},
35 password
=> $conf->{password
},
36 host
=> $conf->{hostname
},
37 cached_fingerprints
=> {
38 $conf->{fingerprint
} => 1
42 __PACKAGE__-
>register_method ({
46 description
=> "Enter container console.",
48 additionalProperties
=> 0,
50 remote
=> get_standard_option
('pveclient-remote-name'),
52 description
=> "The container ID",
57 returns
=> { type
=> 'null'},
61 my $conn = $get_remote_connection->($param->{remote
});
62 my $node = 'localhost'; # ??
64 my $api_path = "api2/json/nodes/$node/lxc/$param->{vmid}";
66 my $res = $conn->get($api_path, {});
68 print to_json
($res, { pretty
=> 1, canonical
=> 1});
73 __PACKAGE__-
>register_method ({
77 description
=> "List containers.",
79 additionalProperties
=> 0,
81 remote
=> get_standard_option
('pveclient-remote-name'),
84 returns
=> { type
=> 'null'},
94 enter
=> [ __PACKAGE__
, 'enter', ['remote', 'vmid']],
95 list
=> [ __PACKAGE__
, 'list', ['remote']],