line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# vim: softtabstop=2 tabstop=2 shiftwidth=2 ft=perl expandtab smarttab |
3
|
|
|
|
|
|
|
# PODNAME: Net::Proxmox::VE::Cluster |
4
|
|
|
|
|
|
|
# ABSTRACT: Functions for the 'cluster' portion of the API |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Net::Proxmox::VE::Cluster; |
10
|
|
|
|
|
|
|
$Net::Proxmox::VE::Cluster::VERSION = '0.37'; |
11
|
1
|
|
|
1
|
|
6
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
69
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1514
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = |
16
|
|
|
|
|
|
|
qw( |
17
|
|
|
|
|
|
|
cluster |
18
|
|
|
|
|
|
|
cluster_backup |
19
|
|
|
|
|
|
|
create_cluster_backup |
20
|
|
|
|
|
|
|
get_cluster_backup |
21
|
|
|
|
|
|
|
update_cluster_backup |
22
|
|
|
|
|
|
|
delete_cluster_backup |
23
|
|
|
|
|
|
|
cluster_ha |
24
|
|
|
|
|
|
|
get_cluster_ha_config |
25
|
|
|
|
|
|
|
get_cluster_ha_changes |
26
|
|
|
|
|
|
|
commit_cluster_ha_changes |
27
|
|
|
|
|
|
|
revert_cluster_ha_changes |
28
|
|
|
|
|
|
|
cluster_ha_groups |
29
|
|
|
|
|
|
|
create_cluster_ha_groups |
30
|
|
|
|
|
|
|
get_cluster_ha_groups |
31
|
|
|
|
|
|
|
update_cluster_ha_groups |
32
|
|
|
|
|
|
|
delete_cluster_ha_group |
33
|
|
|
|
|
|
|
get_cluster_log |
34
|
|
|
|
|
|
|
get_cluster_options |
35
|
|
|
|
|
|
|
update_cluster_options |
36
|
|
|
|
|
|
|
get_cluster_resources |
37
|
|
|
|
|
|
|
get_cluster_status |
38
|
|
|
|
|
|
|
get_cluster_tasks |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $base = '/cluster'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub cluster { |
45
|
|
|
|
|
|
|
|
46
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
return $self->get($base) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub cluster_backup { |
54
|
|
|
|
|
|
|
|
55
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
return $self->get($base, 'backup') |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub create_cluster_backup { |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my @p = @_; |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
croak 'No arguments for create_cluster_backup()' unless @p; |
69
|
0
|
|
|
|
|
|
my %args; |
70
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
72
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for create_cluster_backup()' |
73
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
74
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
else { |
77
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for create_cluster_backup()' |
78
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
79
|
0
|
|
|
|
|
|
%args = @p; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
0
|
|
|
|
|
|
return $self->post( $base, 'backup', \%args ) |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub get_cluster_backup { |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for get_cluster_backup()'; |
92
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for get_cluster_backup()' if ref $a; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
return $self->get( $base, $a ) |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub update_cluster_backup { |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for update_cluster_backup()'; |
104
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for update_cluster_backup()' if ref $a; |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my @p = @_; |
107
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
croak 'No arguments for update_cluster_backup()' unless @p; |
109
|
0
|
|
|
|
|
|
my %args; |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
112
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for update_cluster_backup()' |
113
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
114
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
else { |
117
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for update_cluster_backup()' |
118
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
119
|
0
|
|
|
|
|
|
%args = @p; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return $self->put( $base, 'backup', $a, \%args ) |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub delete_cluster_backup { |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for delete_cluster_backup()'; |
132
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for delete_cluster_backup()' if ref $a; |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
|
return $self->delete( $base, $a ) |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub cluster_ha { |
140
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
return $self->get($base, 'ha') |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub get_cluster_ha_config { |
149
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return $self->get($base, 'ha', 'config') |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub get_cluster_ha_changes { |
158
|
|
|
|
|
|
|
|
159
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return $self->get($base, 'ha', 'changes') |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub commit_cluster_ha_changes { |
167
|
|
|
|
|
|
|
|
168
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
return $self->post($base, 'ha', 'changes') |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub revert_cluster_ha_changes { |
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
178
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
return $self->delete($base, 'ha', 'changes') |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub cluster_ha_groups { |
185
|
|
|
|
|
|
|
|
186
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
187
|
|
|
|
|
|
|
|
188
|
0
|
|
|
|
|
|
return $self->get($base, 'ha','groups') |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
sub create_cluster_ha_groups { |
194
|
|
|
|
|
|
|
|
195
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
my @p = @_; |
198
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
croak 'No arguments for create_cluster_ha_groups()' unless @p; |
200
|
0
|
|
|
|
|
|
my %args; |
201
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
203
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for create_cluster_ha_groups()' |
204
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
205
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
else { |
208
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for create_cluster_ha_groups()' |
209
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
210
|
0
|
|
|
|
|
|
%args = @p; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
return $self->put( $base, 'ha', 'groups', \%args ) |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub get_cluster_ha_groups { |
219
|
|
|
|
|
|
|
|
220
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
221
|
|
|
|
|
|
|
|
222
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for get_cluster_ha_groups()'; |
223
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for get_cluster_ha_groups()' if ref $a; |
224
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return $self->get( $base, 'ha', 'groups', $a ) |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
sub update_cluster_ha_groups { |
232
|
|
|
|
|
|
|
|
233
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
234
|
|
|
|
|
|
|
|
235
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for update_cluster_ha_groups()'; |
236
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for update_cluster_ha_groups()' if ref $a; |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
my @p = @_; |
239
|
|
|
|
|
|
|
|
240
|
0
|
0
|
|
|
|
|
croak 'No arguments for update_cluster_ha_groups()' unless @p; |
241
|
0
|
|
|
|
|
|
my %args; |
242
|
|
|
|
|
|
|
|
243
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
244
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for update_cluster_ha_groups()' |
245
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
246
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
else { |
249
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for update_cluster_ha_groups()' |
250
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
251
|
0
|
|
|
|
|
|
%args = @p; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
0
|
|
|
|
|
|
return $self->put( $base, 'ha', 'groups', $a, \%args ) |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
} |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub delete_cluster_ha_group { |
260
|
|
|
|
|
|
|
|
261
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
262
|
|
|
|
|
|
|
|
263
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No id for delete_cluster_ha_group()'; |
264
|
0
|
0
|
|
|
|
|
croak 'id must be a scalar for delete_cluster_ha_group()' if ref $a; |
265
|
|
|
|
|
|
|
|
266
|
0
|
|
|
|
|
|
return $self->delete( $base, 'ha', 'groups', $a ) |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
} |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub get_cluster_log { |
272
|
|
|
|
|
|
|
|
273
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
|
|
|
|
my @p = @_; |
276
|
|
|
|
|
|
|
|
277
|
0
|
0
|
|
|
|
|
croak 'No arguments for get_cluster_log()' unless @p; |
278
|
0
|
|
|
|
|
|
my %args; |
279
|
|
|
|
|
|
|
|
280
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
281
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for get_cluster_log()' |
282
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
283
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
else { |
286
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for get_cluster_log()' |
287
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
288
|
0
|
|
|
|
|
|
%args = @p; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
return $self->get( $base, 'log', \%args ) |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
sub get_cluster_options { |
297
|
|
|
|
|
|
|
|
298
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
299
|
|
|
|
|
|
|
|
300
|
0
|
|
|
|
|
|
return $self->get($base, 'options') |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
sub update_cluster_options { |
306
|
|
|
|
|
|
|
|
307
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
308
|
|
|
|
|
|
|
|
309
|
0
|
|
|
|
|
|
my @p = @_; |
310
|
|
|
|
|
|
|
|
311
|
0
|
0
|
|
|
|
|
croak 'No arguments for update_cluster_options()' unless @p; |
312
|
0
|
|
|
|
|
|
my %args; |
313
|
|
|
|
|
|
|
|
314
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
315
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for update_cluster_options()' |
316
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
317
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
else { |
320
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for update_cluster_options()' |
321
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
322
|
0
|
|
|
|
|
|
%args = @p; |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
0
|
|
|
|
|
|
return $self->put( $base, 'log', \%args ) |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub get_cluster_resources { |
332
|
|
|
|
|
|
|
|
333
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
334
|
|
|
|
|
|
|
|
335
|
0
|
|
|
|
|
|
my @p = @_; |
336
|
|
|
|
|
|
|
|
337
|
0
|
0
|
|
|
|
|
croak 'No arguments for get_cluster_resources()' unless @p; |
338
|
0
|
|
|
|
|
|
my %args; |
339
|
|
|
|
|
|
|
|
340
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
341
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for get_cluster_resources()' |
342
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
343
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
else { |
346
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for get_cluster_resources()' |
347
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
348
|
0
|
|
|
|
|
|
%args = @p; |
349
|
|
|
|
|
|
|
} |
350
|
|
|
|
|
|
|
|
351
|
0
|
|
|
|
|
|
return $self->get( $base, 'resources', \%args ) |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
|
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
sub get_cluster_status { |
358
|
|
|
|
|
|
|
|
359
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
360
|
|
|
|
|
|
|
|
361
|
0
|
|
|
|
|
|
return $self->get($base, 'status') |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
sub get_cluster_tasks { |
367
|
|
|
|
|
|
|
|
368
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
369
|
|
|
|
|
|
|
|
370
|
0
|
|
|
|
|
|
return $self->get($base, 'tasks') |
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
} |
373
|
|
|
|
|
|
|
|
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
1; |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
__END__ |