VE/Cluster.pm

filter: Statementstmt 10.9% 16 / 146 Branchbran 0.0% 0 / 134 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 14.8% 4 / 27 Podpod 100% 23 / 23 totaltotal 13.0% 43 / 330 CC 68 SCAR 35.0
CC
68
Cov
6%
update_cluster_backup
72.0
update_cluster_ha_groups
72.0
create_cluster_backup
42.0
CRAP 33.2
« VE/Storage.pm ↑ Summary VE/Exception.pm »
1 #!/bin/false
2 # vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab
3 # PODNAME: Net::Proxmox::VE::Cluster
4 # ABSTRACT: Functions for the 'cluster' portion of the API
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 package Net::Proxmox::VE::Cluster;
10 2 $Net::Proxmox::VE::Cluster::VERSION = '0.44';
11 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Net::Proxmox::VE::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our @EXPORT = qw(
16 cluster
17 cluster_backup
18 create_cluster_backup
19 get_cluster_backup
20 update_cluster_backup
21 delete_cluster_backup
22 cluster_ha
23 get_cluster_ha_config
24 get_cluster_ha_changes
25 commit_cluster_ha_changes
26 revert_cluster_ha_changes
27 cluster_ha_groups
28 create_cluster_ha_groups
29 get_cluster_ha_groups
30 update_cluster_ha_groups
31 delete_cluster_ha_group
32 get_cluster_log
33 get_cluster_nextid
34 get_cluster_options
35 update_cluster_options
36 get_cluster_resources
37 get_cluster_status
38 get_cluster_tasks
39 );
40  
41  
42 2 my $BASEPATH = '/cluster';
43  
44 0 ▶sub cluster {
Subroutine cluster: not called CC=2 SCAR=17.9
Pod documented
45  
46 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
47  
48 0 return $self->get($BASEPATH);
49  
50 }
51  
52  
53 0 ▶sub cluster_backup {
Subroutine cluster_backup: not called CC=2 SCAR=17.9
Pod documented
54  
55 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
56  
57 0 return $self->get( $BASEPATH, 'backup' );
58  
59 }
60  
61  
62 0 ▶sub create_cluster_backup {
Subroutine create_cluster_backup: not called CC=6 SCAR=37.4
Pod documented
63  
64 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
65  
66 0 my @p = @_;
67  
68 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
69 'No arguments for create_cluster_backup()')
70 unless @p;
71 0 my %args;
72  
73 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
74 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
75 'Single argument not a hash for create_cluster_backup()')
76 unless ref $p[0] eq 'HASH';
77 0 %args = %{ $p[0] };
78 }
79 else {
80 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
81 'Odd number of arguments for create_cluster_backup()')
82 if ( scalar @p % 2 != 0 );
83 0 %args = @p;
84 }
85  
86 0 return $self->post( $BASEPATH, 'backup', \%args );
87  
88 }
89  
90  
91 0 ▶sub get_cluster_backup {
Subroutine get_cluster_backup: not called CC=4 SCAR=30.0
Pod documented
92  
93 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
94  
95 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for get_cluster_backup()") 0 0 0
96 or Net::Proxmox::VE::Exception->throw('No id for get_cluster_backup()');
97 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
98 'id must be a scalar for get_cluster_backup()')
99 if ref $id;
100  
101 0 return $self->get( $BASEPATH, $id );
102  
103 }
104  
105  
106 0 ▶sub update_cluster_backup {
Subroutine update_cluster_backup: not called CC=8 SCAR=42.8
Pod documented
107  
108 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
109  
110 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for update_cluster_backup()") 0 0 0
111 or
112 Net::Proxmox::VE::Exception->throw('No id for update_cluster_backup()');
113 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
114 'id must be a scalar for update_cluster_backup()')
115 if ref $id;
116  
117 0 my @p = @_;
118  
119 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
120 'No arguments for update_cluster_backup()')
121 unless @p;
122 0 my %args;
123  
124 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
125 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
126 'Single argument not a hash for update_cluster_backup()')
127 unless ref $p[0] eq 'HASH';
128 0 %args = %{ $p[0] };
129 }
130 else {
131 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
132 'Odd number of arguments for update_cluster_backup()')
133 if ( scalar @p % 2 != 0 );
134 0 %args = @p;
135 }
136  
137 0 return $self->put( $BASEPATH, 'backup', $id, \%args );
138  
139 }
140  
141  
142 0 ▶sub delete_cluster_backup {
Subroutine delete_cluster_backup: not called CC=4 SCAR=30.0
Pod documented
143  
144 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
145  
146 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for delete_cluster_backup()") 0 0 0
147 or
148 Net::Proxmox::VE::Exception->throw('No id for delete_cluster_backup()');
149 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
150 'id must be a scalar for delete_cluster_backup()')
151 if ref $id;
152  
153 0 return $self->delete( $BASEPATH, $id );
154  
155 }
156  
157  
158 0 ▶sub cluster_ha {
Subroutine cluster_ha: not called CC=2 SCAR=17.9
Pod documented
159  
160 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
161  
162 0 return $self->get( $BASEPATH, 'ha' );
163  
164 }
165  
166  
167 0 ▶sub get_cluster_ha_config {
Subroutine get_cluster_ha_config: not called CC=2 SCAR=17.9
Pod documented
168  
169 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
170  
171 0 return $self->get( $BASEPATH, 'ha', 'config' );
172  
173 }
174  
175  
176 0 ▶sub get_cluster_ha_changes {
Subroutine get_cluster_ha_changes: not called CC=2 SCAR=17.9
Pod documented
177  
178 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
179  
180 0 return $self->get( $BASEPATH, 'ha', 'changes' );
181  
182 }
183  
184  
185 0 ▶sub commit_cluster_ha_changes {
Subroutine commit_cluster_ha_changes: not called CC=2 SCAR=17.9
Pod documented
186  
187 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
188  
189 0 return $self->post( $BASEPATH, 'ha', 'changes' );
190  
191 }
192  
193  
194 0 ▶sub revert_cluster_ha_changes {
Subroutine revert_cluster_ha_changes: not called CC=2 SCAR=17.9
Pod documented
195  
196 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
197  
198 0 return $self->delete( $BASEPATH, 'ha', 'changes' );
199  
200 }
201  
202  
203 0 ▶sub cluster_ha_groups {
Subroutine cluster_ha_groups: not called CC=2 SCAR=17.9
Pod documented
204  
205 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
206  
207 0 return $self->get( $BASEPATH, 'ha', 'groups' );
208  
209 }
210  
211  
212 0 ▶sub create_cluster_ha_groups {
Subroutine create_cluster_ha_groups: not called CC=6 SCAR=37.4
Pod documented
213  
214 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
215  
216 0 my @p = @_;
217  
218 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
219 'No arguments for create_cluster_ha_groups()')
220 unless @p;
221 0 my %args;
222  
223 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
224 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
225 'Single argument not a hash for create_cluster_ha_groups()')
226 unless ref $p[0] eq 'HASH';
227 0 %args = %{ $p[0] };
228 }
229 else {
230 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
231 'Odd number of arguments for create_cluster_ha_groups()')
232 if ( scalar @p % 2 != 0 );
233 0 %args = @p;
234 }
235  
236 0 return $self->put( $BASEPATH, 'ha', 'groups', \%args );
237  
238 }
239  
240  
241 0 ▶sub get_cluster_ha_groups {
Subroutine get_cluster_ha_groups: not called CC=4 SCAR=30.0
Pod documented
242  
243 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
244  
245 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for get_cluster_ha_groups()") 0 0 0
246 or
247 Net::Proxmox::VE::Exception->throw('No id for get_cluster_ha_groups()');
248 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
249 'id must be a scalar for get_cluster_ha_groups()')
250 if ref $id;
251  
252 0 return $self->get( $BASEPATH, 'ha', 'groups', $id );
253  
254 }
255  
256  
257 0 ▶sub update_cluster_ha_groups {
Subroutine update_cluster_ha_groups: not called CC=8 SCAR=42.8
Pod documented
258  
259 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
260  
261 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for update_cluster_ha_groups()") 0 0 0
262 or Net::Proxmox::VE::Exception->throw(
263 'No id for update_cluster_ha_groups()');
264 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
265 'id must be a scalar for update_cluster_ha_groups()')
266 if ref $id;
267  
268 0 my @p = @_;
269  
270 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
271 'No arguments for update_cluster_ha_groups()')
272 unless @p;
273 0 my %args;
274  
275 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
276 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
277 'Single argument not a hash for update_cluster_ha_groups()')
278 unless ref $p[0] eq 'HASH';
279 0 %args = %{ $p[0] };
280 }
281 else {
282 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
283 'Odd number of arguments for update_cluster_ha_groups()')
284 if ( scalar @p % 2 != 0 );
285 0 %args = @p;
286 }
287  
288 0 return $self->put( $BASEPATH, 'ha', 'groups', $id, \%args );
289  
290 }
291  
292  
293 0 ▶sub delete_cluster_ha_group {
Subroutine delete_cluster_ha_group: not called CC=4 SCAR=30.0
Pod documented
294  
295 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
296  
297 0 ▶ my $id = shift
Branch: 1 branch
BranchTrueFalseTotal
my $id = shift() or "Net::Proxmox::VE::Exception"->throw("No id for delete_cluster_ha_group()") 0 0 0
298 or
299 Net::Proxmox::VE::Exception->throw('No id for delete_cluster_ha_group()');
300 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $id 0 0 0
301 'id must be a scalar for delete_cluster_ha_group()')
302 if ref $id;
303  
304 0 return $self->delete( $BASEPATH, 'ha', 'groups', $id );
305  
306 }
307  
308  
309 0 ▶sub get_cluster_log {
Subroutine get_cluster_log: not called CC=6 SCAR=37.4
Pod documented
310  
311 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
312  
313 0 my @p = @_;
314  
315 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for get_cluster_log()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
316 unless @p;
317 0 my %args;
318  
319 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
320 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
321 'Single argument not a hash for get_cluster_log()')
322 unless ref $p[0] eq 'HASH';
323 0 %args = %{ $p[0] };
324 }
325 else {
326 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
327 'Odd number of arguments for get_cluster_log()')
328 if ( scalar @p % 2 != 0 );
329 0 %args = @p;
330 }
331  
332 0 return $self->get( $BASEPATH, 'log', \%args );
333  
334 }
335  
336  
337 0 ▶sub get_cluster_nextid {
Subroutine get_cluster_nextid: not called CC=6 SCAR=37.4
Pod documented
338  
339 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
340  
341 0 my @p = @_;
342  
343 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for get_cluster_nextid()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
344 unless @p;
345 0 my %args;
346  
347 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
348 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
349 'Single argument not a hash for get_cluster_nextid()')
350 unless ref $p[0] eq 'HASH';
351 0 %args = %{ $p[0] };
352 }
353 else {
354 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
355 'Odd number of arguments for get_cluster_nextid()')
356 if ( scalar @p % 2 != 0 );
357 0 %args = @p;
358 }
359  
360 0 return $self->get( $BASEPATH, 'nextid', \%args );
361  
362 }
363  
364  
365 0 ▶sub get_cluster_options {
Subroutine get_cluster_options: not called CC=2 SCAR=17.9
Pod documented
366  
367 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
368  
369 0 return $self->get( $BASEPATH, 'options' );
370  
371 }
372  
373  
374 0 ▶sub update_cluster_options {
Subroutine update_cluster_options: not called CC=6 SCAR=37.4
Pod documented
375  
376 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
377  
378 0 my @p = @_;
379  
380 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
381 'No arguments for update_cluster_options()')
382 unless @p;
383 0 my %args;
384  
385 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
386 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
387 'Single argument not a hash for update_cluster_options()')
388 unless ref $p[0] eq 'HASH';
389 0 %args = %{ $p[0] };
390 }
391 else {
392 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
393 'Odd number of arguments for update_cluster_options()')
394 if ( scalar @p % 2 != 0 );
395 0 %args = @p;
396 }
397  
398 0 return $self->put( $BASEPATH, 'log', \%args );
399  
400 }
401  
402  
403 0 ▶sub get_cluster_resources {
Subroutine get_cluster_resources: not called CC=6 SCAR=37.4
Pod documented
404  
405 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
406  
407 0 my @p = @_;
408  
409 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
410 'No arguments for get_cluster_resources()')
411 unless @p;
412 0 my %args;
413  
414 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
415 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
416 'Single argument not a hash for get_cluster_resources()')
417 unless ref $p[0] eq 'HASH';
418 0 %args = %{ $p[0] };
419 }
420 else {
421 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
422 'Odd number of arguments for get_cluster_resources()')
423 if ( scalar @p % 2 != 0 );
424 0 %args = @p;
425 }
426  
427 0 return $self->get( $BASEPATH, 'resources', \%args );
428  
429 }
430  
431  
432 0 ▶sub get_cluster_status {
Subroutine get_cluster_status: not called CC=2 SCAR=17.9
Pod documented
433  
434 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
435  
436 0 return $self->get( $BASEPATH, 'status' );
437  
438 }
439  
440  
441 0 ▶sub get_cluster_tasks {
Subroutine get_cluster_tasks: not called CC=2 SCAR=17.9
Pod documented
442  
443 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
444  
445 0 return $self->get( $BASEPATH, 'tasks' );
446  
447 }
448  
449  
450 2 1;
451  
452 __END__
« VE/Storage.pm ↑ Summary VE/Exception.pm »