[pve-devel] [RFC container 1/1] print_ct_warn_log: use log_warn function from RESTEnvironment

Fabian Ebner f.ebner at proxmox.com
Fri Aug 6 14:57:12 CEST 2021


Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 src/PVE/LXC.pm | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index dbdec23..85eed65 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -29,11 +29,11 @@ use PVE::Tools qw(
     $IPV4RE
     $IPV6RE
 );
-use PVE::RPCEnvironment;
 use PVE::CpuSet;
 use PVE::Network;
 use PVE::AccessControl;
 use PVE::ProcFSTools;
+use PVE::RESTEnvironment;
 use PVE::Syscall qw(:fsmount);
 use PVE::LXC::Config;
 use PVE::GuestHelpers qw(safe_string_ne safe_num_ne safe_boolean_ne);
@@ -2296,13 +2296,8 @@ my sub print_ct_warn_log {
     my $log = eval { file_get_contents($log_fn) };
     return if !$log;
 
-    my $rpcenv = eval { PVE::RPCEnvironment::get() };
-
-    my $warn_fn = $rpcenv ? sub { $rpcenv->warn($_[0]) } : sub { print STDERR "WARN: $_[0]\n" };
-
     while ($log =~ /^\h*\s*(.*?)\h*$/gm) {
-	my $line = $1;
-	$warn_fn->($line);
+	PVE::RESTEnvironment::log_warn($1);
     }
     unlink $log_fn or warn "could not unlink '$log_fn' - $!\n";
 }
-- 
2.30.2






More information about the pve-devel mailing list