3 # NOTE: you need to run this on a PVE host, or modify the source to
4 # provide username/password/hostname from somewhere else.
7 use PVE
::APIClient
::LWP
;
9 use PVE
::AccessControl
;
13 # normally you use username/password,
14 # but we can simply create a ticket and CRSF token if we are root
15 # running on a pve host
17 my $hostname = PVE
::INotify
::read_file
("hostname");
19 my $ticket = PVE
::AccessControl
::assemble_ticket
('root@pam');
20 my $csrftoken = PVE
::AccessControl
::assemble_csrf_prevention_token
('root@pam');
22 my $conn = PVE
::APIClient
::LWP-
>new(
23 #username => 'root@pam',
24 #password => 'yourpassword',
26 csrftoken
=> $csrftoken,
28 # allow manual fingerprint verification
29 manual_verification
=> 1,
32 my $res = $conn->get("api2/json/", {});
34 print to_json
($res, { pretty
=> 1, canonical
=> 1});