VE/Storage.pm

filter: Statementstmt 32.6% 16 / 49 Branchbran 0.0% 0 / 36 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 44.4% 4 / 9 Podpod 100% 5 / 5 totaltotal 25.2% 25 / 99 CC 19 SCAR 35.7
CC
19
Cov
19%
update_storage
72.0
create_storage
42.0
get_storage
20.0
CRAP 35.6
« VE/Access.pm ↑ Summary VE/Cluster.pm »
1 #!/bin/false
2 # vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab
3 # PODNAME: Net::Proxmox::VE::Storage
4 # ABSTRACT: Store 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::Storage;
10 2 $Net::Proxmox::VE::Storage::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( storage );
17  
18 2 my $BASEPATH = '/storage';
19  
20  
21 0 ▶sub storage {
Subroutine storage: not called CC=2 SCAR=17.9
Pod documented
22  
23 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
24  
25 0 return $self->get($BASEPATH);
26  
27 }
28  
29  
30 0 ▶sub get_storage {
Subroutine get_storage: not called CC=4 SCAR=30.0
Pod documented
31  
32 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
33  
34 0 ▶ my $storageid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $storageid = shift() or "Net::Proxmox::VE::Exception"->throw("No storageid for get_storage()") 0 0 0
35 or Net::Proxmox::VE::Exception->throw('No storageid for get_storage()');
36 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $storageid 0 0 0
37 'storageid must be a scalar for get_storage()')
38 if ref $storageid;
39  
40 0 return $self->get( $BASEPATH, $storageid );
41  
42 }
43  
44  
45 0 ▶sub create_storage {
Subroutine create_storage: not called CC=6 SCAR=37.4
Pod documented
46  
47 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
48 0 my @p = @_;
49  
50 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for create_storage()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
51 unless @p;
52 0 my %args;
53  
54 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
55 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
56 'Single argument not a hash for create_storage()')
57 unless ref $p[0] eq 'HASH';
58 0 %args = %{ $p[0] };
59 }
60 else {
61 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
62 'Odd number of arguments for create_storage()')
63 if ( scalar @p % 2 != 0 );
64 0 %args = @p;
65 }
66  
67 0 return $self->post( $BASEPATH, \%args );
68  
69 }
70  
71  
72 0 ▶sub delete_storage {
Subroutine delete_storage: not called CC=3 SCAR=24.8
Pod documented
73  
74 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
75 0 ▶ my $storageid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $storageid = shift() or "Net::Proxmox::VE::Exception"->throw("No argument given for delete_storage()") 0 0 0
76 or Net::Proxmox::VE::Exception->throw(
77 'No argument given for delete_storage()');
78  
79 0 return $self->delete( $BASEPATH, $storageid );
80  
81 }
82  
83  
84 0 ▶sub update_storage {
Subroutine update_storage: not called CC=8 SCAR=42.8
Pod documented
85  
86 0 ▶ my $self = shift or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = shift() or return 0 0 0
87 0 ▶ my $storageid = shift
Branch: 1 branch
BranchTrueFalseTotal
my $storageid = shift() or "Net::Proxmox::VE::Exception"->throw("No storageid provided for update_storage()") 0 0 0
88 or Net::Proxmox::VE::Exception->throw(
89 'No storageid provided for update_storage()');
90 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if ref $storageid 0 0 0
91 'storageid must be a scalar for update_storage()')
92 if ref $storageid;
93 0 my @p = @_;
94  
95 0 ▶ Net::Proxmox::VE::Exception->throw('No arguments for update_storage()')
Branch: 1 branch
BranchTrueFalseTotal
unless @p 0 0 0
96 unless @p;
97 0 my %args;
98  
99 0 ▶ if ( @p == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@p == 1) { } 0 0 0
100 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
unless ref $p[0] eq "HASH" 0 0 0
101 'Single argument not a hash for update_storage()')
102 unless ref $p[0] eq 'HASH';
103 0 %args = %{ $p[0] };
104 }
105 else {
106 0 ▶ Net::Proxmox::VE::Exception->throw(
Branch: 1 branch
BranchTrueFalseTotal
if scalar @p % 2 != 0 0 0 0
107 'Odd number of arguments for update_storage()')
108 if ( scalar @p % 2 != 0 );
109 0 %args = @p;
110 }
111  
112 0 return $self->put( $BASEPATH, $storageid, \%args );
113  
114 }
115  
116  
117 2 1;
118  
119 __END__
« VE/Access.pm ↑ Summary VE/Cluster.pm »