[pve-devel] [PATCH access-control] pveum: introduce sub-commands

Philip Abernethy p.abernethy at proxmox.com
Tue Oct 10 16:10:38 CEST 2017


On Tue, Oct 10, 2017 at 04:04:26PM +0200, Thomas Lamprecht wrote:
> Thanks for this, useful to test the other patches.
> 
> I am yet in the process of looking at the code changes but tested
> a bit around. I noticed three problems:
> 
> * when using the `help --verbose` command, e.g.,:
> pveum help --verbose

I've already fixed this yesterday.
> 
> All but the first `USAGE: ...` strings are intended, which wasn't
> the case until now and makes it harder to find/distinguish the
> different sub commands.
> 
> * It would be really nice if the following could work:
> # pveum help user add

This too.
> 
> As with just the quoted version working it can confuse users.
> 
> * bash completion does not seem to work anymore

Using zsh completion never worked for me :D
I'll look into it.
> 
> On 10/09/2017 02:35 PM, Philip Abernethy wrote:
> > use a sub-command structure instead of abbreviated words, where useful.
> > Keep old commands as aliases.
> > ---
> > In case the sub-commands patch gets applied, here is the first use case.
> > 
> >  PVE/CLI/pveum.pm | 41 ++++++++++++++++++++++++++++++-----------
> >  1 file changed, 30 insertions(+), 11 deletions(-)
> > 
> > diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm
> > index aef7089..a4e584d 100755
> > --- a/PVE/CLI/pveum.pm
> > +++ b/PVE/CLI/pveum.pm
> > @@ -38,6 +38,25 @@ sub read_password {
> >  }
> >  
> >  our $cmddef = {
> > +    user => {
> > +	add    => [ 'PVE::API2::User', 'create_user', ['userid'] ],
> > +	modify => [ 'PVE::API2::User', 'update_user', ['userid'] ],
> > +	delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
> > +    },
> > +    group => {
> > +	add    => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
> > +	modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
> > +	delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
> > +    },
> > +    role => {
> > +	add    => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
> > +	modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
> > +	delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
> > +    },
> > +    acl => {
> > +	modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
> > +	delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
> > +    },
> >      ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
> >  		sub {
> >  		    my ($res) = @_;
> > @@ -46,20 +65,20 @@ our $cmddef = {
> >  
> >      passwd => [ 'PVE::API2::AccessControl', 'change_passsword', ['userid'] ],
> >  
> > -    useradd => [ 'PVE::API2::User', 'create_user', ['userid'] ],
> > -    usermod => [ 'PVE::API2::User', 'update_user', ['userid'] ],
> > -    userdel => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
> > +    useradd => { alias => 'user add' },
> > +    usermod => { alias => 'user modify' },
> > +    userdel => { alias => 'user delete' },
> >  
> > -    groupadd => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
> > -    groupmod => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
> > -    groupdel => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
> > +    groupadd => { alias => 'group add' },
> > +    groupmod => { alias => 'group modify' },
> > +    groupdel => { alias => 'group delete' },
> >  
> > -    roleadd => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
> > -    rolemod => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
> > -    roledel => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
> > +    roleadd => { alias => 'role add' },
> > +    rolemod => { alias => 'role modify' },
> > +    roledel => { alias => 'role delete' },
> >  
> > -    aclmod => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }],
> > -    acldel => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }],
> > +    aclmod => { alias => 'acl modify' },
> > +    acldel => { alias => 'acl delete' },
> >  };
> >  
> >  1;
> > 
> 




More information about the pve-devel mailing list