[pve-devel] [RFC] Fix circular dependency on pve-cluster and pve-access-control
Thomas Lamprecht
t.lamprecht at proxmox.com
Tue May 24 18:51:24 CEST 2016
On 24.05.2016 17:09, Dietmar Maurer wrote:
>
> I wonder how we can make that a little bit nicer? Maybe:
>
> diff --git a/data/PVE/pvecm b/data/PVE/pvecm
> index 35f3ff7..87bc9f6 100755
> --- a/data/PVE/pvecm
> +++ b/data/PVE/pvecm
> @@ -17,4 +17,4 @@ my $prepare = sub {
> my $local_ip_address = PVE::Cluster::remote_node_ip($nodename);
> };
>
> -PVE::CLI::pvecm->run_cli(undef, undef, $prepare);
> +PVE::CLI::pvecm->run_cli_handler(prepare => $prepare, no_rpcenv => 1);
>
>
> diff --git a/src/PVE/CLIHandler.pm b/src/PVE/CLIHandler.pm
> index c448a80..612bd27 100644
> --- a/src/PVE/CLIHandler.pm
> +++ b/src/PVE/CLIHandler.pm
> @@ -473,6 +473,7 @@ sub run_cli_handler {
>
> 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 +487,12 @@ sub run_cli_handler {
>
> PVE::INotify::inotify_init() if !$no_init;
>
> - my $rpcenv = PVE::RPCEnvironment->init('cli');
> - $rpcenv->init_request() if !$no_init;
> - $rpcenv->set_language($ENV{LANG});
> - $rpcenv->set_user('root at pam');
> + 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');
> + }
> }
>
> no strict 'refs';
>
looks better/cleaner to me, yes. Maybe default to no_rpcen = 1 if class is /^PVE::Service/ and its not explicitly set and rename the param to no_cli_rpcenv as its a environment for cli?
I'll send a patch.
More information about the pve-devel
mailing list