[pve-devel] [PATCH access-control v2 2/2] pveum: add list and dump commands

Stoiko Ivanov s.ivanov at proxmox.com
Tue May 29 16:32:06 CEST 2018


* Adds list for all objects currently handled in the CLI
* Adds dump for User and Group
* Relies on print_text_table and print_entry being present in PVE::CLIHandler
  (Patches submitted independently)

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 PVE/CLI/pveum.pm | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
index a4e584d..b73b133 100755
--- a/PVE/CLI/pveum.pm
+++ b/PVE/CLI/pveum.pm
@@ -42,20 +42,43 @@ our $cmddef = {
 	add    => [ 'PVE::API2::User', 'create_user', ['userid'] ],
 	modify => [ 'PVE::API2::User', 'update_user', ['userid'] ],
 	delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
+	list   => [ 'PVE::API2::User', 'index', [], {}, sub {
+	    __PACKAGE__->print_text_table( [ { key => 'userid', cutoff => 64 },
+			    { key => 'enabled', default => 1 } ], shift, shift);
+	    } ],
+	dump   => [ 'PVE::API2::User', 'read_user', ['userid'], undef, sub {
+	    __PACKAGE__->print_entry(shift) } ],
     },
     group => {
 	add    => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
 	modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
 	delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
+	list   => [ 'PVE::API2::Group', 'index', [], {}, sub {
+	    __PACKAGE__->print_text_table([{ key => 'groupid'}], shift, shift);
+	} ],
+	dump   => [ 'PVE::API2::Group', 'read_group', ['groupid'], undef, sub {
+	    __PACKAGE__->print_entry(shift) } ],
     },
     role => {
 	add    => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
 	modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
 	delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
+	list   => [ 'PVE::API2::Role', 'index', [], {}, sub {
+	    __PACKAGE__->print_text_table( [ { key => 'roleid', cutoff => 30 },
+			    { key => 'special' },
+			    { key => 'privs' } ], shift, shift);
+	    } ],
     },
     acl => {
 	modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
 	delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
+	list   => [ 'PVE::API2::ACL', 'read_acl', [], {}, sub {
+	    __PACKAGE__->print_text_table( [ { key => 'type',},
+			    { key => 'ugid',},
+			    { key => 'roleid', },
+			    { key => 'propagate', },
+			    { key => 'path' } ], shift, shift);
+	    } ],
     },
     ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
 		sub {
-- 
2.11.0





More information about the pve-devel mailing list