| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/bin/false |
|
2
|
|
|
|
|
|
|
# vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab |
|
3
|
|
|
|
|
|
|
# PODNAME: Net::Proxmox::VE::Pools |
|
4
|
|
|
|
|
|
|
# ABSTRACT: Presents a pool object |
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
155795
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
75
|
|
|
7
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
202
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Net::Proxmox::VE::Pools; |
|
10
|
|
|
|
|
|
|
$Net::Proxmox::VE::Pools::VERSION = '0.44'; |
|
11
|
2
|
|
|
2
|
|
17
|
use parent 'Exporter'; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
741
|
use Net::Proxmox::VE::Exception; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1403
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( |
|
17
|
|
|
|
|
|
|
pools |
|
18
|
|
|
|
|
|
|
get_pool |
|
19
|
|
|
|
|
|
|
create_pool |
|
20
|
|
|
|
|
|
|
delete_pool |
|
21
|
|
|
|
|
|
|
update_pool |
|
22
|
|
|
|
|
|
|
); |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $BASEPATH = '/pools'; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub pools { |
|
28
|
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
|
30
|
0
|
|
|
|
|
|
my @p = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# optional query parameters |
|
33
|
0
|
0
|
|
|
|
|
if (@p) { |
|
34
|
0
|
|
|
|
|
|
my %args; |
|
35
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
|
36
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
37
|
|
|
|
|
|
|
'Single argument not a hash for pools()') |
|
38
|
|
|
|
|
|
|
unless ref $p[0] eq 'HASH'; |
|
39
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
|
0
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else { |
|
42
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
43
|
|
|
|
|
|
|
'Odd number of arguments for pools()') |
|
44
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
|
45
|
0
|
|
|
|
|
|
%args = @p; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
0
|
|
|
|
|
|
return $self->get( $BASEPATH, \%args ); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
return $self->get($BASEPATH); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_pool { |
|
56
|
|
|
|
|
|
|
|
|
57
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
|
58
|
|
|
|
|
|
|
|
|
59
|
0
|
0
|
|
|
|
|
my $poolid = shift |
|
60
|
|
|
|
|
|
|
or Net::Proxmox::VE::Exception->throw('No poolid for get_pool()'); |
|
61
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('poolid must be a scalar for get_pool()') |
|
62
|
|
|
|
|
|
|
if ref $poolid; |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
return $self->get( $BASEPATH, $poolid ); |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub create_pool { |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
|
72
|
0
|
|
|
|
|
|
my @p = @_; |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('No arguments for create_pool()') |
|
75
|
|
|
|
|
|
|
unless @p; |
|
76
|
0
|
|
|
|
|
|
my %args; |
|
77
|
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
|
79
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
80
|
|
|
|
|
|
|
'Single argument not a hash for create_pool()') |
|
81
|
|
|
|
|
|
|
unless ref $p[0] eq 'HASH'; |
|
82
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
|
0
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
else { |
|
85
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
86
|
|
|
|
|
|
|
'Odd number of arguments for create_pool()') |
|
87
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
|
88
|
0
|
|
|
|
|
|
%args = @p; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# enforce required poolid |
|
92
|
|
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('poolid is required for create_pool()') |
|
93
|
0
|
0
|
0
|
|
|
|
unless exists $args{poolid} && defined $args{poolid}; |
|
94
|
|
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('poolid must be a scalar for create_pool()') |
|
95
|
0
|
0
|
|
|
|
|
if ref $args{poolid}; |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $self->post( $BASEPATH, \%args ); |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub delete_pool { |
|
103
|
|
|
|
|
|
|
|
|
104
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
|
105
|
0
|
0
|
|
|
|
|
my $poolid = shift |
|
106
|
|
|
|
|
|
|
or |
|
107
|
|
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('No argument given for delete_pool()'); |
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $self->delete( $BASEPATH, $poolid ); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub update_pool { |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
|
117
|
0
|
0
|
|
|
|
|
my $poolid = shift |
|
118
|
|
|
|
|
|
|
or Net::Proxmox::VE::Exception->throw( |
|
119
|
|
|
|
|
|
|
'No poolid provided for update_pool()'); |
|
120
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
121
|
|
|
|
|
|
|
'poolid must be a scalar for update_pool()') |
|
122
|
|
|
|
|
|
|
if ref $poolid; |
|
123
|
0
|
|
|
|
|
|
my @p = @_; |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw('No arguments for update_pool()') |
|
126
|
|
|
|
|
|
|
unless @p; |
|
127
|
0
|
|
|
|
|
|
my %args; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
|
130
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
131
|
|
|
|
|
|
|
'Single argument not a hash for update_pool()') |
|
132
|
|
|
|
|
|
|
unless ref $p[0] eq 'HASH'; |
|
133
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
|
0
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
else { |
|
136
|
0
|
0
|
|
|
|
|
Net::Proxmox::VE::Exception->throw( |
|
137
|
|
|
|
|
|
|
'Odd number of arguments for update_pool()') |
|
138
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
|
139
|
0
|
|
|
|
|
|
%args = @p; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
return $self->put( $BASEPATH, $poolid, \%args ); |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=pod |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=encoding UTF-8 |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 NAME |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Net::Proxmox::VE::Pools - Presents a pool object |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 VERSION |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
version 0.44 |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
@pools = $obj->pools(); |
|
166
|
|
|
|
|
|
|
$pool = $obj->get_pool( $poolid ); |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
$ok = $obj->create_pool(%args); |
|
169
|
|
|
|
|
|
|
$ok = $obj->create_pool(\%args); |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
$ok = $obj->delete_pool( $poolid ); |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$ok = $obj->update_pool( $poolid, %args); |
|
174
|
|
|
|
|
|
|
$ok = $obj->update_pool( $poolid, \%args); |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
This module implements the 'pools' section of the Proxmox API for L<Net::Proxmox::VE>, |
|
179
|
|
|
|
|
|
|
you should use the API via that module. This documentation is for detailed reference. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
To be clear, this module isn't useful as a stand alone piece of software. |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Pools can be used to group a set of virtual machines and datastores. You can then simply |
|
184
|
|
|
|
|
|
|
set permissions on pools, which are inherited by all pool members. This is a great way |
|
185
|
|
|
|
|
|
|
to simplify access control. |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 NOTE |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
String formats that are mentioned herein are done so for convenience and |
|
190
|
|
|
|
|
|
|
are defined in detail in the Proxmox API documents on the Proxmox project website. |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
This module doesn't enforce them, it will send whatever garbage you provide |
|
193
|
|
|
|
|
|
|
straight to the server API. So garbage-in, garbage-out! |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 METHODS |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 pools |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Gets a list of pools or get a single pool configuration.. |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
Accepts optional query parameters (hashref or key/value list) to filter results. |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Examples: |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# list all pools |
|
206
|
|
|
|
|
|
|
@pools = $obj->pools(); |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# retrieve a single pool via query parameter (preferred; replaces deprecated get_pool()) |
|
209
|
|
|
|
|
|
|
@one = $obj->pools({ poolid => 'mypool' }); |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# filter by pool id and type |
|
212
|
|
|
|
|
|
|
@filtered = $obj->pools( poolid => 'mypool', type => 'qemu' ); |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
Available types (at time of writing) are: qemu, lxc, storage |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=head2 get_pool |
|
217
|
|
|
|
|
|
|
DEPRECATED IN API: The Proxmox API marks the per-pool endpoint as deprecated (no support for nested pools). |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This module retains `get_pool()` for backward compatibility and will continue to provide it |
|
220
|
|
|
|
|
|
|
until the Proxmox API removes the endpoint. New code should use `pools()` with the |
|
221
|
|
|
|
|
|
|
`poolid` query parameter (preferred), |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Retrieves a single storage pool |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
$pool = $obj->get_pool( $poolid ); |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
Where $poolid is a string in pve-poolid format |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 create_pool |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Creates a new pool |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
$ok = $obj->create_pool( %args ); |
|
234
|
|
|
|
|
|
|
$ok = $obj->create_pool( \%args ); |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
I<%args> may items contain from the following list |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=over 4 |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item poolid |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
String. The id of the pool you wish to access, in pve-poolid format. This is required. |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=item comment |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
String. This is a comment associated with the new pool, this is optional |
|
247
|
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=back |
|
249
|
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 delete_pool |
|
251
|
|
|
|
|
|
|
DEPRECATED IN API: The Proxmox API marks the per-pool delete endpoint as deprecated (no support for nested pools). |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
This module keeps `update_pool()` for backward compatibility and will remove the |
|
254
|
|
|
|
|
|
|
subroutine when the API no longer exposes the per-pool endpoint. |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Deletes a single pool |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$ok = $obj->delete_pool( $poolid ) |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Where $poolid is a string in pve-poolid format |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head2 update_pool |
|
263
|
|
|
|
|
|
|
DEPRECATED IN API: The Proxmox API marks the per-pool update endpoint as deprecated (no support for nested pools). |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
This module keeps `update_pool()` for backward compatibility and will remove the |
|
266
|
|
|
|
|
|
|
subroutine when the API no longer exposes the per-pool endpoint. |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
Updates (sets) a pool's data |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
$ok = $obj->update_pool( $poolid, %args ); |
|
271
|
|
|
|
|
|
|
$ok = $obj->update_pool( $poolid, \%args ); |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Where $poolid is a string in pve-poolid format |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
I<%args> may items contain from the following list |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=over 4 |
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item comment |
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
String. This is a comment associated with the new pool, this is optional |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item delete |
|
284
|
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Boolean. Removes the vms/storage rather than adding it. |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item storage |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
String. List of storage ids (in pve-storage-id-list format) |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item vms |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
String. List of virtual machines in pve-vmid-list format. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=back |
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
L<Net::Proxmox::VE> |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
=head1 AUTHOR |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
Dean Hamstead <dean@fragfest.com.au> |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
This software is Copyright (c) 2026 by Dean Hamstead. |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
This is free software, licensed under: |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
The MIT (X11) License |
|
312
|
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
=cut |