]>
Commit | Line | Data |
---|---|---|
09281ad7 DM |
1 | package PVE::CLI::pveum; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use Getopt::Long; | |
6 | use PVE::Tools qw(run_command); | |
7 | use PVE::Cluster; | |
8 | use PVE::SafeSyslog; | |
9 | use PVE::AccessControl; | |
10 | use File::Path qw(make_path remove_tree); | |
09281ad7 DM |
11 | use PVE::INotify; |
12 | use PVE::RPCEnvironment; | |
13 | use PVE::API2::User; | |
14 | use PVE::API2::Group; | |
15 | use PVE::API2::Role; | |
16 | use PVE::API2::ACL; | |
17 | use PVE::API2::AccessControl; | |
18 | use PVE::JSONSchema qw(get_standard_option); | |
19 | use PVE::CLIHandler; | |
b34d76e7 | 20 | use PVE::PTY; |
09281ad7 DM |
21 | |
22 | use base qw(PVE::CLIHandler); | |
23 | ||
e623414a DM |
24 | sub setup_environment { |
25 | PVE::RPCEnvironment->setup_default_cli_env(); | |
26 | } | |
27 | ||
b34d76e7 DC |
28 | sub param_mapping { |
29 | my ($name) = @_; | |
98007830 | 30 | |
b34d76e7 DC |
31 | my $mapping = { |
32 | 'change_password' => [ | |
33 | PVE::CLIHandler::get_standard_mapping('pve-password'), | |
34 | ], | |
35 | 'create_ticket' => [ | |
36 | PVE::CLIHandler::get_standard_mapping('pve-password', { | |
37 | func => sub { | |
38 | # do not accept values given on cmdline | |
39 | return PVE::PTY::read_password('Enter password: '); | |
40 | }, | |
41 | }), | |
42 | ] | |
43 | }; | |
44 | ||
45 | return $mapping->{$name}; | |
98007830 DM |
46 | } |
47 | ||
09281ad7 | 48 | our $cmddef = { |
1e41cdc9 PA |
49 | user => { |
50 | add => [ 'PVE::API2::User', 'create_user', ['userid'] ], | |
51 | modify => [ 'PVE::API2::User', 'update_user', ['userid'] ], | |
52 | delete => [ 'PVE::API2::User', 'delete_user', ['userid'] ], | |
53 | }, | |
54 | group => { | |
55 | add => [ 'PVE::API2::Group', 'create_group', ['groupid'] ], | |
56 | modify => [ 'PVE::API2::Group', 'update_group', ['groupid'] ], | |
57 | delete => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ], | |
58 | }, | |
59 | role => { | |
60 | add => [ 'PVE::API2::Role', 'create_role', ['roleid'] ], | |
61 | modify => [ 'PVE::API2::Role', 'update_role', ['roleid'] ], | |
62 | delete => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ], | |
63 | }, | |
64 | acl => { | |
65 | modify => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 0 }], | |
66 | delete => [ 'PVE::API2::ACL', 'update_acl', ['path'], { delete => 1 }], | |
67 | }, | |
09281ad7 DM |
68 | ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef, |
69 | sub { | |
70 | my ($res) = @_; | |
71 | print "$res->{ticket}\n"; | |
72 | }], | |
73 | ||
765305e2 | 74 | passwd => [ 'PVE::API2::AccessControl', 'change_password', ['userid'] ], |
09281ad7 | 75 | |
1e41cdc9 PA |
76 | useradd => { alias => 'user add' }, |
77 | usermod => { alias => 'user modify' }, | |
78 | userdel => { alias => 'user delete' }, | |
09281ad7 | 79 | |
1e41cdc9 PA |
80 | groupadd => { alias => 'group add' }, |
81 | groupmod => { alias => 'group modify' }, | |
82 | groupdel => { alias => 'group delete' }, | |
09281ad7 | 83 | |
1e41cdc9 PA |
84 | roleadd => { alias => 'role add' }, |
85 | rolemod => { alias => 'role modify' }, | |
86 | roledel => { alias => 'role delete' }, | |
09281ad7 | 87 | |
1e41cdc9 PA |
88 | aclmod => { alias => 'acl modify' }, |
89 | acldel => { alias => 'acl delete' }, | |
09281ad7 DM |
90 | }; |
91 | ||
92 | 1; |