[pve-devel] [PATCH access-control v7] pveum: add list and dump commands

Stoiko Ivanov s.ivanov at proxmox.com
Mon Aug 6 20:13:07 CEST 2018


* Adds list for all objects currently handled in the CLI
* Adds dump for User and Group
* Uses print_api_result from PVE::CLIFormatter

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
Changes from v6:
* adapt to the latest changes to our CLI handling in pve-common
.
 PVE/CLI/pveum.pm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
index 5fd15fe..a42f14b 100755
--- a/PVE/CLI/pveum.pm
+++ b/PVE/CLI/pveum.pm
@@ -17,6 +17,7 @@ use PVE::API2::ACL;
 use PVE::API2::AccessControl;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::CLIHandler;
+use PVE::CLIFormatter;
 use PVE::PTY;
 
 use base qw(PVE::CLIHandler);
@@ -50,20 +51,44 @@ 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 {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, ['userid', 'enable'], $options);
+	}, $PVE::RESTHandler::standard_output_options ],
+	dump   => [ 'PVE::API2::User', 'read_user', ['userid'], undef, sub {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
+	}, $PVE::RESTHandler::standard_output_options ],
     },
     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 {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, ['groupid'], $options);
+	}, $PVE::RESTHandler::standard_output_options ],
+	dump   => [ 'PVE::API2::Group', 'read_group', ['groupid'], undef, sub {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
+	}, $PVE::RESTHandler::standard_output_options ],
     },
     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 {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, ['roleid', 'special', 'privs'], $options);
+	}, $PVE::RESTHandler::standard_output_options ],
     },
     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 {
+	    my ($data, $schema, $options) = @_;
+	    PVE::CLIFormatter::print_api_result($data, $schema, ['ugid', 'roleid', 'propagate', 'path'], $options);
+	}, $PVE::RESTHandler::standard_output_options ],
     },
     ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
 		sub {
-- 
2.11.0





More information about the pve-devel mailing list