[pve-devel] [PATCH access-control] RFC: add ls command for pvum user
Stoiko Ivanov
s.ivanov at proxmox.com
Mon May 7 14:00:08 CEST 2018
partially addresses #1502
Given that this is my first patch to this list I would appreciate feedback!
---
PVE/CLI/pveum.pm | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
index a4e584d..f744398 100755
--- a/PVE/CLI/pveum.pm
+++ b/PVE/CLI/pveum.pm
@@ -42,6 +42,25 @@ our $cmddef = {
add => [ 'PVE::API2::User', 'create_user', ['userid'] ],
modify => [ 'PVE::API2::User', 'update_user', ['userid'] ],
delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
+ ls => [ 'PVE::API2::User', 'index', [], {}, sub {
+ my $userlist = shift;
+ printf "%-30s %-7s\n",
+ qw(USERID ENABLED);
+ foreach my $user (sort{ $a->{userid} cmp $b->{userid}} @$userlist) {
+ printf "%-30s %-7d\n", $user->{userid}, $user->{enable}//1;
+ }
+ } ],
+ get => [ 'PVE::API2::User', 'read_user', ['userid'], undef, sub {
+ my $userdata = shift;
+ foreach my $item (sort keys %$userdata) {
+ if( ref($userdata->{$item}) eq 'ARRAY'){
+ printf "%s: [ %s ]\n", $item, join ", ",
+ @{$userdata->{$item}};
+ } else {
+ printf "%s: %-7s\n", $item, $userdata->{$item};
+ }
+ }
+ } ],
},
group => {
add => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
--
2.11.0
More information about the pve-devel
mailing list