MetaAPI/API/Volume.pm

filter: Statementstmt 77.1% 27 / 35 Branchbran 42.8% 6 / 14 Conditioncond 33.3% 2 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 77.7% 7 / 9 Podpod 0.0% 0 / 5 totaltotal 58.9% 43 / 73 CC 11 SCAR 18.7
CC
11
Cov
64%
volume_from_uid
20.0
volume_limits
6.0
__ANON__
3.1
CRAP 6.5
« MetaAPI/API/Specs/Roles/Service.pm ↑ Summary MetaAPI/Roles/GetFromId.pm »
1 package OpenStack::MetaAPI::API::Volume;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 extends 'OpenStack::MetaAPI::API::Service';
9  
10 1 with 'OpenStack::MetaAPI::Roles::Listable';
11  
12 # Block storage is in the catalogue under whichever versions the cloud still
13 # offers, and 'volume' unadorned is not always one of them -- a current
14 # deployment may list only volumev3 and volumev2. So the type is whatever is
15 # actually there, newest first, rather than a name we picked in advance.
16 has '+name' => (
17 required => 0,
18 lazy => 1,
19 1 ▶ default => sub {
Subroutine __ANON__: called CC=3 SCAR=11.4
20 1 my ($self) = @_;
21  
22 1 my %offered = map { $_ => 1 } $self->auth->services;
23 1 foreach my $type (qw{volumev3 volumev2 volume}) {
24 1 ▶ return $type if $offered{$type};
Branch: 1 branch
BranchTrueFalseTotal
if $offered{$type} 1 0 1
25 }
26  
27 0 die "This cloud offers no block storage service (looked for volumev3, volumev2, volume)\n";
28 },
29 1 );
30  
31 # Declared here rather than in a Specs data block.
32 #
33 # The spec package a service loads is named after its catalogue type -- so a
34 # cloud offering volumev3 would want Specs::Volumev3, and one offering volume
35 # would want Specs::Volume, for the same two routes. Writing them out once is
36 # less work than one spec file per spelling.
37 1 ▶sub volumes {
Subroutine volumes: called CC=1 SCAR=0.0
Pod undocumented
38 1 my ($self, @args) = @_;
39  
40 1 return $self->_list(['/volumes', 'volumes'], \@args);
41 }
42  
43 0 ▶sub volume_from_uid {
Subroutine volume_from_uid: not called CC=4 SCAR=30.0
Pod undocumented
44 0 my ($self, $uid) = @_;
45  
46 0 ▶ die "volume id is required by volume_from_uid" unless defined $uid && length $uid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uid and length $uid 0 0 0
Condition0%0/3
defined $uid and length $uid
!ll&&!rl&&r
000
MC/DC0%0/2
defined $uid and length $uid
defined $uid length $uid
Truth table0%0/3
A and B
A= defined $uidB= length $uid
ABresult
0X0
100
111
47  
48 0 my $out = $self->get($self->root_uri("/volumes/$uid"));
49  
50 0 ▶ return ref $out ? $out->{volume} : $out;
Branch: 1 branch
BranchTrueFalseTotal
ref $out ? : 0 0 0
51 }
52  
53 2 ▶sub create_volume {
Subroutine create_volume: called CC=3 SCAR=11.0
Pod undocumented
54 2 my ($self, %opts) = @_;
55  
56 2 ▶ die "'size' is required by create_volume" unless $opts{size};
Branch: 1 branch
BranchTrueFalseTotal
unless $opts{"size"} 1 1 2
57  
58 1 my $out = $self->post($self->root_uri('/volumes'), {volume => {%opts}});
59  
60 1 ▶ return ref $out ? $out->{volume} : $out;
Branch: 1 branch
BranchTrueFalseTotal
ref $out ? : 1 0 1
61 }
62  
63 2 ▶sub delete_volume {
Subroutine delete_volume: called CC=3 SCAR=11.0
Pod undocumented
64 2 my ($self, $uid) = @_;
65  
66 2 ▶ die "volume id is required by delete_volume" unless defined $uid && length $uid;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uid and length $uid 1 1 2
Condition66%2/3
defined $uid and length $uid
!ll&&!rl&&r
011
MC/DC50%1/2
defined $uid and length $uid
defined $uid length $uid
Truth table66%2/3
A and B
A= defined $uidB= length $uid
ABresult
0X0
100
111
67  
68 1 return $self->delete($self->root_uri("/volumes/$uid"));
69 }
70  
71 0 ▶sub volume_limits {
Subroutine volume_limits: not called CC=2 SCAR=17.9
Pod undocumented
72 0 my ($self) = @_;
73  
74 0 my $out = $self->get($self->root_uri('/limits'));
75  
76 0 ▶ return ref $out ? $out->{limits} : $out;
Branch: 1 branch
BranchTrueFalseTotal
ref $out ? : 0 0 0
77 }
78  
79 1 1;
80  
81 __END__
« MetaAPI/API/Specs/Roles/Service.pm ↑ Summary MetaAPI/Roles/GetFromId.pm »