[pve-devel] [PATCH common] run_cli_handler: add no_rpcenv parameter

Thomas Lamprecht t.lamprecht at proxmox.com
Wed May 25 11:03:10 CEST 2016


This can be used if a CLIHandler child class does not needs or wants
RPCEnv. E.g. this is the case with pve-cluster, as it's a dependency
of the package where RPCEnv resides (access-control), so this can be
set to avoid a implicit circular build dependency.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/CLIHandler.pm | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
index c448a80..2a9a6c9 100644
--- a/src/PVE/CLIHandler.pm
+++ b/src/PVE/CLIHandler.pm
@@ -468,11 +468,13 @@ sub run_cli_handler {
     foreach my $key (keys %params) {
 	next if $key eq 'prepare';
 	next if $key eq 'no_init'; # used by lxc hooks
+	next if $key eq 'no_rpcenv';
 	die "unknown parameter '$key'";
     }
 
     my $preparefunc = $params{prepare};
     my $no_init = $params{no_init};
+    my $no_rpcenv = $params{no_rpcenv};
 
     my $pwcallback = $class->can('read_password');
     my $stringfilemap = $class->can('string_param_file_mapping');
@@ -486,10 +488,12 @@ sub run_cli_handler {
 
 	PVE::INotify::inotify_init() if !$no_init;
 
+	if (!$no_rpcenv) {
 	my $rpcenv = PVE::RPCEnvironment->init('cli');
-	$rpcenv->init_request() if !$no_init;
-	$rpcenv->set_language($ENV{LANG});
-	$rpcenv->set_user('root at pam');
+	    $rpcenv->init_request() if !$no_init;
+	    $rpcenv->set_language($ENV{LANG});
+	    $rpcenv->set_user('root at pam');
+	}
     }
 
     no strict 'refs';
-- 
2.1.4





More information about the pve-devel mailing list