pveum: add list commands

we already have the API paths, and they make sense to get an overview
over user.cfg contents.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2019-11-21 15:43:21 +01:00 committed by Thomas Lamprecht
parent a5ec58ea9a
commit 369851ac6d

View File

@ -9,8 +9,10 @@ use PVE::API2::Group;
use PVE::API2::Role; use PVE::API2::Role;
use PVE::API2::ACL; use PVE::API2::ACL;
use PVE::API2::AccessControl; use PVE::API2::AccessControl;
use PVE::CLIFormatter;
use PVE::CLIHandler; use PVE::CLIHandler;
use PVE::PTY; use PVE::PTY;
use PVE::RESTHandler;
use base qw(PVE::CLIHandler); use base qw(PVE::CLIHandler);
@ -38,25 +40,34 @@ sub param_mapping {
return $mapping->{$name}; return $mapping->{$name};
} }
my $print_api_result = sub {
my ($data, $schema, $options) = @_;
PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
};
our $cmddef = { our $cmddef = {
user => { user => {
add => [ 'PVE::API2::User', 'create_user', ['userid'] ], add => [ 'PVE::API2::User', 'create_user', ['userid'] ],
modify => [ 'PVE::API2::User', 'update_user', ['userid'] ], modify => [ 'PVE::API2::User', 'update_user', ['userid'] ],
delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ], delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
list => [ 'PVE::API2::User', 'index', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
}, },
group => { group => {
add => [ 'PVE::API2::Group', 'create_group', ['groupid'] ], add => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ], modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ], delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
list => [ 'PVE::API2::Group', 'index', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
}, },
role => { role => {
add => [ 'PVE::API2::Role', 'create_role', ['roleid'] ], add => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ], modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ], delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
list => [ 'PVE::API2::Role', 'index', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
}, },
acl => { acl => {
modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }], modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }], delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
list => [ 'PVE::API2::ACL', 'read_acl', [], {}, $print_api_result, $PVE::RESTHandler::standard_output_options],
}, },
ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef, ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
sub { sub {