sdn: prefer proxy from datacenter.cfg for api calls

We only setup proxies from the environment previously, but also check
the one configured in the cluster-wide datacenter.cfg and prefer that
over anything else.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
Alexandre Derumier 2024-01-04 17:11:35 +01:00 committed by Thomas Lamprecht
parent 9f4525c350
commit 6e96fd3314

View file

@ -264,10 +264,9 @@ sub api_request {
my $req = HTTP::Request->new($method,$url, $headers, $encoded_data); my $req = HTTP::Request->new($method,$url, $headers, $encoded_data);
my $ua = LWP::UserAgent->new(protocols_allowed => ['http', 'https'], timeout => 30); my $ua = LWP::UserAgent->new(protocols_allowed => ['http', 'https'], timeout => 30);
my $proxy = undef; my $datacenter_cfg = PVE::Cluster::cfs_read_file('datacenter.cfg');
if (my $proxy = $datacenter_cfg->{http_proxy}) {
if ($proxy) { $ua->proxy(['http', 'https'], $proxy);
$ua->proxy(['http', 'https'], $proxy);
} else { } else {
$ua->env_proxy; $ua->env_proxy;
} }