| 1 | package OpenStack::MetaAPI::API::Compute; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # use Client::Lite::API role | ||||||||||||||||||||||||||||
| 9 | #with 'OpenStack::MetaAPI::API'; ... | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 3 | extends 'OpenStack::MetaAPI::API::Service'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # roles | ||||||||||||||||||||||||||||
| 14 | #with 'OpenStack::MetaAPI::Roles::DataAsYaml'; | ||||||||||||||||||||||||||||
| 15 | 3 | with 'OpenStack::MetaAPI::Roles::Listable'; | |||||||||||||||||||||||||||
| 16 | 3 | with 'OpenStack::MetaAPI::Roles::GetFromId'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 3 | has '+name' => (default => 'compute'); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub delete_server { | ||||||||||||||||||||||||||||
| 21 | 2 | ▶ | my ($self, $uid) = @_; | ||||||||||||||||||||||||||
|
Subroutine
delete_server: called CC=7 SCAR=20.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # first check that the server exists | ||||||||||||||||||||||||||||
| 24 | 2 | my $server = $self->api->server_from_uid($uid); | |||||||||||||||||||||||||||
| 25 | 2 | ▶ | return unless ref $server && $server->{id} eq $uid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $server and $server->{"id"} eq $uid
MC/DC0%0/2
ref $server and $server->{"id"} eq $uid
ref $server
$server->{"id"} eq $uid
Truth table33%1/3
A and B
A= ref $serverB= $server->{"id"} eq $uid
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 2 | my $api = $self->api; | |||||||||||||||||||||||||||
| 28 | { | ||||||||||||||||||||||||||||
| 29 | # delete floating ip for device [maybe provide its own helper at the main level of API] | ||||||||||||||||||||||||||||
| 30 | 2 | my $port_for_device = $api->ports(device_id => $uid); | |||||||||||||||||||||||||||
| 31 | 2 | ▶ | if ($port_for_device && $port_for_device->{id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$port_for_device and $port_for_device->{"id"}
MC/DC50%1/2
$port_for_device and $port_for_device->{"id"}
$port_for_device
$port_for_device->{"id"}
Truth table66%2/3
A and B
A= $port_for_deviceB= $port_for_device->{"id"}
| |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | my $port_id = $port_for_device->{id}; | |||||||||||||||||||||||||||
| 34 | 1 | my $floatingip = $api->floatingips(port_id => $port_id); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | if ($floatingip && $floatingip->{id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$floatingip and $floatingip->{"id"}
MC/DC0%0/2
$floatingip and $floatingip->{"id"}
$floatingip
$floatingip->{"id"}
Truth table33%1/3
A and B
A= $floatingipB= $floatingip->{"id"}
| |||||||||||||||||||||||||||||
| 37 | 1 | $api->delete_floatingip($floatingip->{id}); | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # maybe need to wait? | ||||||||||||||||||||||||||||
| 43 | 2 | my $uri = $self->root_uri('/servers/' . $uid); | |||||||||||||||||||||||||||
| 44 | 2 | return $self->delete($uri); | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # FIXME should be generated from specs | ||||||||||||||||||||||||||||
| 48 | sub create_server { | ||||||||||||||||||||||||||||
| 49 | 2 | ▶ | my ($self, %opts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
create_server: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 2 | my $uri = $self->root_uri('/servers/'); | |||||||||||||||||||||||||||
| 52 | 2 | my $output = $self->post($uri, {server => {%opts}}); | |||||||||||||||||||||||||||
| 53 | 2 | ▶ | return $output->{server} if ref $output; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | return $output; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | ### helpers | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 3 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =pod | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | =head1 NAME | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | OpenStack::MetaAPI::API::Compute | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head1 VERSION | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | version 0.002 | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | Nicolas R <atoomic@cpan.org> | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | This software is copyright (c) 2019 by cPanel, Inc. | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 84 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =cut | ||||||||||||||||||||||||||||