run_cli_handler: add no_rpcenv parameter

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@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2016-05-25 11:03:10 +02:00 committed by Dietmar Maurer
parent 6e537f49bd
commit 361d54c329

View File

@ -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,11 +488,13 @@ 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@pam');
}
}
no strict 'refs';
my $def = ${"${class}::cmddef"};