| 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
| |||||||||||||||||||||||||||||
| 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
Condition0%0/3
defined $uid and length $uid
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
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | my $out = $self->get($self->root_uri("/volumes/$uid")); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | return ref $out ? $out->{volume} : $out; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
Condition66%2/3
defined $uid and length $uid
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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 1 | 1; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | __END__ | ||||||||||||||||||||||||||||