]>
git.proxmox.com Git - pve-client.git/blob - PVE/APIClient/Config.pm
1 package PVE
::APIClient
::Config
;
9 use PVE
::APIClient
::LWP
;
13 my $filename = home
() . '/.pveclient';
14 my $conf_str = PVE
::Tools
::file_get_contents
($filename);
16 my $filemode = (stat($filename))[2] & 07777;
17 if ($filemode != 0600) {
18 die sprintf "wrong permissions on '$filename' %04o (expected 0600)\n", $filemode;
21 return decode_json
($conf_str);
24 sub load_remote_config
{
27 my $conf = load_config
();
29 my $remote_conf = $conf->{"remote_$remote"} ||
30 die "no such remote '$remote'\n";
32 foreach my $opt (qw(hostname username password fingerprint)) {
33 die "missing option '$opt' (remote '$remote')" if !defined($remote_conf->{$opt});
39 sub get_remote_connection
{
42 my $conf = load_remote_config
($remote);
44 return PVE
::APIClient
::LWP-
>new(
45 username
=> $conf->{username
},
46 password
=> $conf->{password
},
47 host
=> $conf->{hostname
},
48 cached_fingerprints
=> {
49 $conf->{fingerprint
} => 1