line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package OpenStack::MetaAPI::Routes; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
38
|
use strict; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
171
|
|
4
|
6
|
|
|
6
|
|
34
|
use warnings; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
139
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
2853
|
use Moo; |
|
6
|
|
|
|
|
63168
|
|
|
6
|
|
|
|
|
27
|
|
7
|
|
|
|
|
|
|
|
8
|
6
|
|
|
6
|
|
10289
|
use OpenStack::MetaAPI::API (); |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
113
|
|
9
|
6
|
|
|
6
|
|
2231
|
use YAML::XS; |
|
6
|
|
|
|
|
15079
|
|
|
6
|
|
|
|
|
318
|
|
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
2413
|
use OpenStack::MetaAPI::Helpers::DataAsYaml; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
2268
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'auth' => (is => 'ro'); |
14
|
|
|
|
|
|
|
has 'api' => (is => 'ro'); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $ROUTES; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub init_once { |
19
|
6
|
|
33
|
6
|
0
|
44
|
$ROUTES //= OpenStack::MetaAPI::Helpers::DataAsYaml::LoadData(); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# cannot read from data block at compile time |
23
|
|
|
|
|
|
|
#INIT { init_once() } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub list_all { |
26
|
6
|
|
|
6
|
0
|
83
|
init_once(); |
27
|
6
|
|
|
|
|
104
|
return sort keys %$ROUTES; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
0
|
|
|
sub DESTROY { |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
our $AUTOLOAD; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub AUTOLOAD { |
36
|
39
|
|
|
39
|
|
32931
|
my (@args) = @_; |
37
|
39
|
|
|
|
|
68
|
my $call_for = $AUTOLOAD; |
38
|
|
|
|
|
|
|
|
39
|
39
|
|
|
|
|
154
|
$call_for =~ s/.*:://; |
40
|
|
|
|
|
|
|
|
41
|
39
|
50
|
|
|
|
160
|
if (my $route = $ROUTES->{$call_for}) { |
42
|
39
|
50
|
|
|
|
110
|
die "$call_for is a method call" unless ref $args[0] eq __PACKAGE__; |
43
|
39
|
|
|
|
|
64
|
my $self = shift @args; |
44
|
|
|
|
|
|
|
|
45
|
39
|
|
|
|
|
109
|
my $service = $self->service($route->{service}); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# not easy to overwrite can if Moo/XS::Accessor |
48
|
39
|
|
|
|
|
143
|
my $controller = $service->can_method($call_for); |
49
|
|
|
|
|
|
|
|
50
|
39
|
50
|
|
|
|
80
|
die "Invalid route '$call_for' for service '" . ref($service) . "'" |
51
|
|
|
|
|
|
|
unless defined $controller; |
52
|
|
|
|
|
|
|
|
53
|
39
|
|
|
|
|
112
|
return $controller->($service, @args); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
die "Unknown function $call_for from AUTOLOAD"; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub service { |
60
|
39
|
|
|
39
|
0
|
82
|
my ($self, $name) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# cache the service once |
63
|
39
|
|
|
|
|
76
|
my $k = '_service_' . $name; |
64
|
39
|
100
|
|
|
|
97
|
if (!$self->{$k}) { |
65
|
|
|
|
|
|
|
$self->{$k} = OpenStack::MetaAPI::API::get_service( |
66
|
|
|
|
|
|
|
name => $name, auth => $self->auth, |
67
|
8
|
|
|
|
|
73
|
region => $ENV{'OS_REGION_NAME'}, |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# backreference |
70
|
|
|
|
|
|
|
api => $self->api, |
71
|
|
|
|
|
|
|
); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
39
|
|
|
|
|
91
|
return $self->{$k}; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
## this data block describes the routes |
80
|
|
|
|
|
|
|
# this could be moved to a file... |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=pod |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=encoding UTF-8 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 NAME |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
OpenStack::MetaAPI::Routes |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 VERSION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
version 0.003 |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Nicolas R |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This software is copyright (c) 2019 by cPanel, Inc. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
103
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__DATA__ |