]>
Commit | Line | Data |
---|---|---|
bc39c284 | 1 | #!/usr/bin/perl |
d12f292e DM |
2 | |
3 | # NOTE: you need to run this on a PVE host, or modify the source to | |
4 | # provide username/password/hostname from somewhere else. | |
5 | ||
6 | use strict; | |
bc39c284 DM |
7 | use warnings; |
8 | ||
d12f292e DM |
9 | use PVE::APIClient::LWP; |
10 | ||
11 | use PVE::AccessControl; | |
12 | use PVE::INotify; | |
13 | use JSON; | |
14 | ||
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 | |
18 | ||
19 | my $hostname = PVE::INotify::read_file("hostname"); | |
20 | ||
21 | my $ticket = PVE::AccessControl::assemble_ticket('root@pam'); | |
22 | my $csrftoken = PVE::AccessControl::assemble_csrf_prevention_token('root@pam'); | |
23 | ||
24 | my $conn = PVE::APIClient::LWP->new( | |
25 | #username => 'root@pam', | |
26 | #password => 'yourpassword', | |
27 | ticket => $ticket, | |
28 | csrftoken => $csrftoken, | |
29 | host => $hostname, | |
30 | # allow manual fingerprint verification | |
31 | manual_verification => 1, | |
32 | ); | |
33 | ||
ce70bf81 | 34 | my $res = $conn->get("/", {}); |
d12f292e DM |
35 | |
36 | print to_json($res, { pretty => 1, canonical => 1}); |