VE/Pools.pm

filter: Statementstmt 26.2% 16 / 61 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 44.4% 4 / 9 Podpod 100% 5 / 5 totaltotal 19.5% 25 / 128 CC 26 SCAR 39.5
CC
26
Cov
14%
create_pool
90.0
update_pool
72.0
pools
42.0
CRAP 51.7
« VE/Nodes.pm ↑ Summary VE/Access.pm »
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 ▶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::Pools;
10 2 $Net::Proxmox::VE::Pools::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  
16 2 our @EXPORT = qw(
17 pools
18 get_pool
19 create_pool
20 delete_pool
21 update_pool
22 );
23  
24 2 my $BASEPATH = '/pools';
25  
26  
27 0 ▶sub pools {
Subroutine pools: not called CC=6 SCAR=37.4
Pod documented
28  
29 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
30 0 my @p = @_;
31  
32 # optional query parameters
33 0 ▶ if (@p) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p) 0 0 0
34 0 my %args;
35 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
36 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
37 'Single argument not a hash for pools()')
38 unless ref $p[0] eq 'HASH';
39 0 %args = %{ $p[0] };
40 }
41 else {
42 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
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 0 ▶sub get_pool {
Subroutine get_pool: not called CC=4 SCAR=30.0
Pod documented
56  
57 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
58  
59 0 ▶ my $poolid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $poolid = shift() or "Net::Proxmox::VE::Exception"->throw("No poolid for get_pool()") 0 0 0
60 or Net::Proxmox::VE::Exception->throw('No poolid for get_pool()');
61 0 ▶ Net::Proxmox::VE::Exception->throw('poolid must be a scalar for get_pool()')
Branch: 1 branch
BranchTrueFalseTotal
if ref $poolid 0 0 0
62 if ref $poolid;
63  
64 0 return $self->get( $BASEPATH, $poolid );
65  
66 }
67  
68  
69 0 ▶sub create_pool {
Subroutine create_pool: not called CC=9 SCAR=45.0
Pod documented
70  
71 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
72 0 my @p = @_;
73  
74 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for create_pool()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
75 unless @p;
76 0 my %args;
77  
78 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
79 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
80 'Single argument not a hash for create_pool()')
81 unless ref $p[0] eq 'HASH';
82 0 %args = %{ $p[0] };
83 }
84 else {
85 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
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 ▶ unless exists $args{poolid} && defined $args{poolid};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $args{"poolid"} and defined $args{"poolid"} 0 0 0
Condition0%0/3
exists $args{"poolid"} and defined $args{"poolid"}
!ll&&!rl&&r
000
MC/DC0%0/2
exists $args{"poolid"} and defined $args{"poolid"}
exists $args{"poolid"} defined $args{"poolid"}
Truth table0%0/3
A and B
A= exists $args{"poolid"}B= defined $args{"poolid"}
ABresult
0X0
100
111
94 Net::Proxmox::VE::Exception->throw('poolid must be a scalar for create_pool()')
95 0 ▶ if ref $args{poolid};
Branch: 1 branch
BranchTrueFalseTotal
if ref $args{"poolid"} 0 0 0
96  
97 0 return $self->post( $BASEPATH, \%args );
98  
99 }
100  
101  
102 0 ▶sub delete_pool {
Subroutine delete_pool: not called CC=3 SCAR=24.8
Pod documented
103  
104 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
105 0 ▶ my $poolid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $poolid = shift() or "Net::Proxmox::VE::Exception"->throw("No argument given for delete_pool()") 0 0 0
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 0 ▶sub update_pool {
Subroutine update_pool: not called CC=8 SCAR=42.8
Pod documented
115  
116 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
117 0 ▶ my $poolid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $poolid = shift() or "Net::Proxmox::VE::Exception"->throw("No poolid provided for update_pool()") 0 0 0
118 or Net::Proxmox::VE::Exception->throw(
119 'No poolid provided for update_pool()');
120 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $poolid 0 0 0
121 'poolid must be a scalar for update_pool()')
122 if ref $poolid;
123 0 my @p = @_;
124  
125 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for update_pool()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
126 unless @p;
127 0 my %args;
128  
129 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
130 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
131 'Single argument not a hash for update_pool()')
132 unless ref $p[0] eq 'HASH';
133 0 %args = %{ $p[0] };
134 }
135 else {
136 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
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 2 1;
148  
149 __END__
« VE/Nodes.pm ↑ Summary VE/Access.pm »