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