[pve-devel] [RFC] Fix circular dependency on pve-cluster and pve-access-control

Dietmar Maurer dietmar at proxmox.com
Tue May 24 17:09:56 CEST 2016


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';




More information about the pve-devel mailing list