| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package OpenStack::MetaAPI::API::Compute; |
|
2
|
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
22
|
use strict; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
101
|
|
|
4
|
3
|
|
|
3
|
|
19
|
use warnings; |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
76
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
15
|
use Moo; |
|
|
3
|
|
|
|
|
7
|
|
|
|
3
|
|
|
|
|
23
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# use Client::Lite::API role |
|
9
|
|
|
|
|
|
|
#with 'OpenStack::MetaAPI::API'; ... |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
extends 'OpenStack::MetaAPI::API::Service'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# roles |
|
14
|
|
|
|
|
|
|
#with 'OpenStack::MetaAPI::Roles::DataAsYaml'; |
|
15
|
|
|
|
|
|
|
with 'OpenStack::MetaAPI::Roles::Listable'; |
|
16
|
|
|
|
|
|
|
with 'OpenStack::MetaAPI::Roles::GetFromId'; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has '+name' => (default => 'compute'); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub delete_server { |
|
21
|
2
|
|
|
2
|
0
|
6
|
my ($self, $uid) = @_; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# first check that the server exists |
|
24
|
2
|
|
|
|
|
46
|
my $server = $self->api->server_from_uid($uid); |
|
25
|
2
|
50
|
33
|
|
|
12
|
return unless ref $server && $server->{id} eq $uid; |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
|
|
8
|
my $api = $self->api; |
|
28
|
|
|
|
|
|
|
{ |
|
29
|
|
|
|
|
|
|
# delete floating ip for device [maybe provide its own helper at the main level of API] |
|
30
|
2
|
|
|
|
|
5
|
my $port_for_device = $api->ports(device_id => $uid); |
|
|
2
|
|
|
|
|
54
|
|
|
31
|
2
|
50
|
66
|
|
|
11
|
if ($port_for_device && $port_for_device->{id}) { |
|
32
|
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
3
|
my $port_id = $port_for_device->{id}; |
|
34
|
1
|
|
|
|
|
27
|
my $floatingip = $api->floatingips(port_id => $port_id); |
|
35
|
|
|
|
|
|
|
|
|
36
|
1
|
50
|
33
|
|
|
9
|
if ($floatingip && $floatingip->{id}) { |
|
37
|
1
|
|
|
|
|
28
|
$api->delete_floatingip($floatingip->{id}); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# maybe need to wait? |
|
43
|
2
|
|
|
|
|
2274
|
my $uri = $self->root_uri('/servers/' . $uid); |
|
44
|
2
|
|
|
|
|
38
|
return $self->delete($uri); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# FIXME should be generated from specs |
|
48
|
|
|
|
|
|
|
sub create_server { |
|
49
|
2
|
|
|
2
|
0
|
19
|
my ($self, %opts) = @_; |
|
50
|
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
7
|
my $uri = $self->root_uri('/servers/'); |
|
52
|
2
|
|
|
|
|
73
|
my $output = $self->post($uri, {server => {%opts}}); |
|
53
|
2
|
50
|
|
|
|
4085
|
return $output->{server} if ref $output; |
|
54
|
0
|
|
|
|
|
|
return $output; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
### helpers |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |