]> git.proxmox.com Git - pve-access-control.git/blame - pveum
add pool API
[pve-access-control.git] / pveum
CommitLineData
2c3a6c0a
DM
1#!/usr/bin/perl -w
2
3use strict;
4use Getopt::Long;
5use PVE::Tools qw(run_command);
6use PVE::Cluster;
7use PVE::SafeSyslog;
8use PVE::AccessControl;
9use File::Path qw(make_path remove_tree);
10use Term::ReadLine;
11use PVE::INotify;
12use PVE::RPCEnvironment;
13use PVE::API2::User;
14use PVE::API2::Group;
15use PVE::API2::Role;
16use PVE::API2::ACL;
39c85db8 17use PVE::API2::Pool;
2c3a6c0a
DM
18use PVE::API2::AccessControl;
19use PVE::JSONSchema qw(get_standard_option);
20use PVE::CLIHandler;
21
22use base qw(PVE::CLIHandler);
23
24use Data::Dumper; # fixme: remove
25
26$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
27
28initlog('pveum');
29
30#fixme: logging?
31
32die "please run as root\n" if $> != 0;
33
34PVE::INotify::inotify_init();
35
36my $rpcenv = PVE::RPCEnvironment->init('cli');
37
38$rpcenv->init_request();
39$rpcenv->set_language($ENV{LANG});
40$rpcenv->set_user('root@pam');
41
42# autmatically generate the private key if it does not already exists
43PVE::Cluster::gen_auth_key();
44
45my $read_password = sub {
46
47 # return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET});
48
49 my $term = new Term::ReadLine ('pveum');
50 my $attribs = $term->Attribs;
51 $attribs->{redisplay_function} = $attribs->{shadow_redisplay};
52 my $input = $term->readline('Enter new password: ');
53 my $conf = $term->readline('Retype new password: ');
54 die "Passwords do not match.\n" if ($input ne $conf);
55 return $input;
56};
57
58my $cmddef = {
59 ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef,
60 sub {
61 my ($res) = @_;
62 print "$res->{ticket}\n";
63 }],
64 useradd => [ 'PVE::API2::User', 'create_user', ['userid'] ],
65 usermod => [ 'PVE::API2::User', 'update_user', ['userid'] ],
66 userdel => [ 'PVE::API2::User', 'delete_user', ['userid'] ],
67
68 groupadd => [ 'PVE::API2::Group', 'create_group', ['groupid'] ],
69 groupmod => [ 'PVE::API2::Group', 'update_group', ['groupid'] ],
70 groupdel => [ 'PVE::API2::Group', 'delete_group', ['groupid'] ],
71
72 roleadd => [ 'PVE::API2::Role', 'create_role', ['roleid'] ],
73 rolemod => [ 'PVE::API2::Role', 'update_role', ['roleid'] ],
74 roledel => [ 'PVE::API2::Role', 'delete_role', ['roleid'] ],
75
39c85db8
DM
76 pooladd => [ 'PVE::API2::Pool', 'create_pool', ['poolid'] ],
77 poolmod => [ 'PVE::API2::Pool', 'update_pool', ['poolid'] ],
78 pooldel => [ 'PVE::API2::Pool', 'delete_pool', ['poolid'] ],
79
2c3a6c0a
DM
80 aclmod => [ 'PVE::API2::ACL', 'update_acl', ['path', 'roles'], { delete => 0 }],
81 acldel => [ 'PVE::API2::ACL', 'update_acl', ['path', 'roles'], { delete => 1 }],
82};
83
84my $cmd = shift;
85
362fe4c6 86PVE::CLIHandler::handle_cmd($cmddef, "pveum", $cmd, \@ARGV, $read_password, $0);
2c3a6c0a
DM
87
88exit 0;
89
90__END__
91
92=head1 NAME
93
94pveum - PVE User Manager
95
96=head1 SYNOPSIS
97
362fe4c6 98=include synopsis
2c3a6c0a
DM
99
100=head1 DESCRIPTION
101
362fe4c6
DM
102No description available.
103
104=include pve_copyright