]> git.proxmox.com Git - pve-access-control.git/commitdiff
pveum: work around unavailable API2:Pools module
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 9 May 2021 17:46:53 +0000 (19:46 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sun, 9 May 2021 17:48:50 +0000 (19:48 +0200)
commit 42ade84744ab60ff8e452d3e562a36dd3da2b810 added the pool
subcommands, reusing the PVE::API2::Pool module. But that module has
to live in pve-manager and is not available here, most of the time
not a real issue (but always ugly), on bootstrapping this becomes a
blocker though...

So, for now add a hack and do not hard depend on the modules
availability...

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/CLI/pveum.pm

index cbbdb7db2509f95a88beba80db697762966c5ff8..59297070066458cfd8da7e7250c5a27377ea8ee1 100755 (executable)
@@ -10,7 +10,6 @@ use PVE::API2::Group;
 use PVE::API2::Role;
 use PVE::API2::ACL;
 use PVE::API2::AccessControl;
 use PVE::API2::Role;
 use PVE::API2::ACL;
 use PVE::API2::AccessControl;
-use PVE::API2::Pool;
 use PVE::API2::Domains;
 use PVE::CLIFormatter;
 use PVE::CLIHandler;
 use PVE::API2::Domains;
 use PVE::CLIFormatter;
 use PVE::CLIHandler;
@@ -146,12 +145,6 @@ our $cmddef = {
        delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
        list   => [ 'PVE::API2::ACL', 'read_acl', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
     },
        delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
        list   => [ 'PVE::API2::ACL', 'read_acl', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
     },
-    pool => {
-       add => [ 'PVE::API2::Pool', 'create_pool', ['poolid'] ],
-       modify => [ 'PVE::API2::Pool', 'update_pool', ['poolid'] ],
-       delete => [ 'PVE::API2::Pool', 'delete_pool', ['poolid'] ],
-       list   => [ 'PVE::API2::Pool', 'index', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
-    },
     realm => {
        add    => [ 'PVE::API2::Domains', 'create', ['realm'] ],
        modify => [ 'PVE::API2::Domains', 'update', ['realm'] ],
     realm => {
        add    => [ 'PVE::API2::Domains', 'create', ['realm'] ],
        modify => [ 'PVE::API2::Domains', 'update', ['realm'] ],
@@ -184,4 +177,22 @@ our $cmddef = {
     acldel => { alias => 'acl delete' },
 };
 
     acldel => { alias => 'acl delete' },
 };
 
+# FIXME: HACK! The pool API is in pve-manager as it needs access to storage guest and RRD stats,
+# so we only add the pool commands if the API module is available (required for boots-trapping)
+my $have_pool_api;
+eval {
+    require PVE::API2::Pool;
+    PVE::API2::Pool->import();
+    $have_pool_api = 1;
+};
+
+if ($have_pool_api) {
+    $cmddef->{pool} = {
+       add => [ 'PVE::API2::Pool', 'create_pool', ['poolid'] ],
+       modify => [ 'PVE::API2::Pool', 'update_pool', ['poolid'] ],
+       delete => [ 'PVE::API2::Pool', 'delete_pool', ['poolid'] ],
+       list   => [ 'PVE::API2::Pool', 'index', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
+    };
+}
+
 1;
 1;