Fix #1922. In some cases we want most of the settings done like for a standard CLI environment, without setting the type 'cli'.
This is needed in cases where we don't want to receive the log-output of fork_worker, which prints it to stdout if run via a 'cli' environment without the background argument. For #1922 this is needed when calling pvesh via ssh with --output_format json in case a call gets proxied to another node. Signed-off-by: Stoiko Ivanov <[email protected]> --- src/PVE/RESTEnvironment.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/PVE/RESTEnvironment.pm b/src/PVE/RESTEnvironment.pm index aca18bc..47a527a 100644 --- a/src/PVE/RESTEnvironment.pm +++ b/src/PVE/RESTEnvironment.pm @@ -141,14 +141,20 @@ sub init { # convenience function for command line tools sub setup_default_cli_env { my ($class, $username) = @_; + $class->setup_default_env($username, 'cli'); +} + +sub setup_default_env { + my ($class, $username, $type) = @_; $class = ref($class) || $class; $username //= 'root@pam'; + $type //= 'cli'; PVE::INotify::inotify_init(); - my $rpcenv = $class->init('cli'); + my $rpcenv = $class->init($type); $rpcenv->init_request(); $rpcenv->set_language($ENV{LANG}); $rpcenv->set_user($username); -- 2.11.0 _______________________________________________ pve-devel mailing list [email protected] https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
