| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::Base; |
|
2
|
6
|
|
|
6
|
|
88687
|
use Carp; |
|
|
6
|
|
|
|
|
20
|
|
|
|
6
|
|
|
|
|
445
|
|
|
3
|
6
|
|
|
6
|
|
391
|
use Mouse; |
|
|
6
|
|
|
|
|
29824
|
|
|
|
6
|
|
|
|
|
137
|
|
|
4
|
6
|
|
|
6
|
|
3551
|
use JSON; |
|
|
6
|
|
|
|
|
17409
|
|
|
|
6
|
|
|
|
|
58
|
|
|
5
|
6
|
|
|
6
|
|
6028
|
use Furl; |
|
|
6
|
|
|
|
|
155839
|
|
|
|
6
|
|
|
|
|
278
|
|
|
6
|
6
|
|
|
6
|
|
384
|
use Data::Validator; |
|
|
6
|
|
|
|
|
2963
|
|
|
|
6
|
|
|
|
|
206
|
|
|
7
|
6
|
|
|
6
|
|
1970
|
use namespace::clean -except => 'meta'; |
|
|
6
|
|
|
|
|
78168
|
|
|
|
6
|
|
|
|
|
56
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has auth_token => ( is => 'rw' ); |
|
10
|
|
|
|
|
|
|
has service_catalog => ( is => 'rw' ); |
|
11
|
|
|
|
|
|
|
has auth_url => ( is => 'rw', required => 1 ); |
|
12
|
|
|
|
|
|
|
has user => ( is => 'rw', required => 1 ); |
|
13
|
|
|
|
|
|
|
has password => ( is => 'rw', required => 1 ); |
|
14
|
|
|
|
|
|
|
has tenant_name => ( is => 'rw' ); |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#has verify_ssl => (is => 'ro', default => sub {! $ENV{OSCOMPUTE_INSECURE}}); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has agent => ( |
|
19
|
|
|
|
|
|
|
is => 'rw', |
|
20
|
|
|
|
|
|
|
lazy => 1, |
|
21
|
|
|
|
|
|
|
default => sub { |
|
22
|
|
|
|
|
|
|
my $self = shift; |
|
23
|
|
|
|
|
|
|
my $agent = Furl->new; |
|
24
|
|
|
|
|
|
|
return $agent; |
|
25
|
|
|
|
|
|
|
}, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
0
|
0
|
0
|
sub get_auth_params { die; } |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub service_catalog_url_for { |
|
31
|
1
|
|
|
1
|
0
|
4568
|
my $self = shift; |
|
32
|
|
|
|
|
|
|
my $rule = Data::Validator->new( |
|
33
|
|
|
|
|
|
|
endpoint_type => { |
|
34
|
|
|
|
|
|
|
isa => 'Str', |
|
35
|
0
|
|
|
0
|
|
0
|
default => sub { 'object-store' } |
|
36
|
|
|
|
|
|
|
}, |
|
37
|
|
|
|
|
|
|
service_type => { |
|
38
|
|
|
|
|
|
|
isa => 'Str', |
|
39
|
0
|
|
|
0
|
|
0
|
default => sub { 'publicURL' } |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
1
|
|
|
|
|
20
|
region => { isa => 'Str', default => undef }, |
|
42
|
|
|
|
|
|
|
); |
|
43
|
1
|
|
|
|
|
200
|
my $args = $rule->validate(@_); |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
70
|
my $found_endpoint; |
|
46
|
1
|
|
|
|
|
2
|
LOOP: foreach my $service_catelog ( @{ $self->service_catalog } ) { |
|
|
1
|
|
|
|
|
5
|
|
|
47
|
1
|
50
|
|
|
|
4
|
if ( $args->{service_type} eq $service_catelog->{type} ) { |
|
48
|
1
|
|
|
|
|
2
|
foreach my $endpoint ( @{ $service_catelog->{endpoints} } ) { |
|
|
1
|
|
|
|
|
2
|
|
|
49
|
1
|
50
|
|
|
|
4
|
if ( exists $endpoint->{ $args->{endpoint_type} } ) { |
|
50
|
|
|
|
|
|
|
# check if the region matches or if there is no prefered region |
|
51
|
1
|
50
|
33
|
|
|
3
|
if ( !$args->{region} or $args->{region} eq $endpoint->{region} ) { |
|
52
|
1
|
|
|
|
|
2
|
$found_endpoint = $endpoint; |
|
53
|
|
|
|
|
|
|
# we found it, stop searching |
|
54
|
1
|
|
|
|
|
3
|
last LOOP; |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
} |
|
60
|
1
|
50
|
|
|
|
4
|
unless ($found_endpoint) { |
|
61
|
0
|
|
|
|
|
0
|
croak sprintf( "%s endpoint for %s service not found", $args->{endpoint_type}, $args->{service_type} ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
1
|
|
|
|
|
10
|
return $found_endpoint->{ $args->{endpoint_type} }; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::V1_0; |
|
67
|
6
|
|
|
6
|
|
6082
|
use Carp; |
|
|
6
|
|
|
|
|
79
|
|
|
|
6
|
|
|
|
|
411
|
|
|
68
|
6
|
|
|
6
|
|
40
|
use JSON; |
|
|
6
|
|
|
|
|
19
|
|
|
|
6
|
|
|
|
|
88
|
|
|
69
|
6
|
|
|
6
|
|
854
|
use Mouse; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
68
|
|
|
70
|
6
|
|
|
6
|
|
3104
|
use namespace::clean -except => 'meta'; |
|
|
6
|
|
|
|
|
20
|
|
|
|
6
|
|
|
|
|
34
|
|
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
extends 'Net::OpenStack::Swift::InnerKeystone::Base'; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub get_auth_params { |
|
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
76
|
|
|
|
|
|
|
return { |
|
77
|
0
|
|
|
|
|
|
auth => { |
|
78
|
|
|
|
|
|
|
tenantName => 'no-needed', |
|
79
|
|
|
|
|
|
|
passwordCredentials => { |
|
80
|
|
|
|
|
|
|
username => $self->user, |
|
81
|
|
|
|
|
|
|
password => $self->password, |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
}; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub auth { |
|
88
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
89
|
0
|
|
|
|
|
|
my $res = $self->agent->get( |
|
90
|
|
|
|
|
|
|
$self->auth_url, |
|
91
|
|
|
|
|
|
|
[ |
|
92
|
|
|
|
|
|
|
'X-Auth-Key' => $self->password, |
|
93
|
|
|
|
|
|
|
'X-Auth-User' => $self->user |
|
94
|
|
|
|
|
|
|
] |
|
95
|
|
|
|
|
|
|
); |
|
96
|
0
|
0
|
|
|
|
|
croak "authorization failed: " . $res->status_line unless $res->is_success; |
|
97
|
0
|
|
|
|
|
|
my $body_params = from_json( $res->content ); |
|
98
|
0
|
|
|
|
|
|
my $url = $body_params->{storage}->{ $self->tenant_name }; |
|
99
|
0
|
|
|
|
|
|
$self->auth_token( $res->header('X-Auth-Token') ); |
|
100
|
0
|
|
|
|
|
|
$self->service_catalog( |
|
101
|
|
|
|
|
|
|
[ |
|
102
|
|
|
|
|
|
|
{ |
|
103
|
|
|
|
|
|
|
type => 'object-store', |
|
104
|
|
|
|
|
|
|
endpoints => [ { endpoint_type => 'publicURL', publicURL => $url } ] |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
] |
|
107
|
|
|
|
|
|
|
); |
|
108
|
0
|
|
|
|
|
|
return $self->auth_token(); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::V2_0; |
|
112
|
6
|
|
|
6
|
|
3950
|
use Carp; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
359
|
|
|
113
|
6
|
|
|
6
|
|
39
|
use JSON; |
|
|
6
|
|
|
|
|
15
|
|
|
|
6
|
|
|
|
|
23
|
|
|
114
|
6
|
|
|
6
|
|
625
|
use Mouse; |
|
|
6
|
|
|
|
|
11
|
|
|
|
6
|
|
|
|
|
29
|
|
|
115
|
6
|
|
|
6
|
|
2158
|
use namespace::clean -except => 'meta'; |
|
|
6
|
|
|
|
|
16
|
|
|
|
6
|
|
|
|
|
29
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
extends 'Net::OpenStack::Swift::InnerKeystone::Base'; |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub get_auth_params { |
|
120
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
121
|
|
|
|
|
|
|
return { |
|
122
|
0
|
|
|
|
|
|
auth => { |
|
123
|
|
|
|
|
|
|
tenantName => $self->tenant_name, |
|
124
|
|
|
|
|
|
|
passwordCredentials => { |
|
125
|
|
|
|
|
|
|
username => $self->user, |
|
126
|
|
|
|
|
|
|
password => $self->password, |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
}; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub auth { |
|
133
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
134
|
0
|
|
|
|
|
|
my $res = $self->agent->post( |
|
135
|
|
|
|
|
|
|
$self->auth_url . "/tokens", |
|
136
|
|
|
|
|
|
|
[ 'Content-Type' => 'application/json' ], |
|
137
|
|
|
|
|
|
|
to_json( $self->get_auth_params ), |
|
138
|
|
|
|
|
|
|
); |
|
139
|
0
|
0
|
|
|
|
|
croak "authorization failed: " . $res->status_line unless $res->is_success; |
|
140
|
0
|
|
|
|
|
|
my $body_params = from_json( $res->content ); |
|
141
|
0
|
|
|
|
|
|
$self->auth_token( $body_params->{access}->{token}->{id} ); |
|
142
|
0
|
|
|
|
|
|
$self->service_catalog( $body_params->{access}->{serviceCatalog} ); |
|
143
|
0
|
|
|
|
|
|
return $self->auth_token(); |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::V3_0; |
|
147
|
6
|
|
|
6
|
|
3910
|
use Carp; |
|
|
6
|
|
|
|
|
18
|
|
|
|
6
|
|
|
|
|
356
|
|
|
148
|
6
|
|
|
6
|
|
38
|
use JSON; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
36
|
|
|
149
|
6
|
|
|
6
|
|
696
|
use Mouse; |
|
|
6
|
|
|
|
|
17
|
|
|
|
6
|
|
|
|
|
30
|
|
|
150
|
6
|
|
|
6
|
|
2341
|
use namespace::clean -except => 'meta'; |
|
|
6
|
|
|
|
|
14
|
|
|
|
6
|
|
|
|
|
28
|
|
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
extends 'Net::OpenStack::Swift::InnerKeystone::Base'; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
0
|
0
|
|
sub get_auth_params { |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#return { |
|
157
|
|
|
|
|
|
|
# auth => { |
|
158
|
|
|
|
|
|
|
# identity => { |
|
159
|
|
|
|
|
|
|
# methods => ['password'], |
|
160
|
|
|
|
|
|
|
# password => { |
|
161
|
|
|
|
|
|
|
# user => { |
|
162
|
|
|
|
|
|
|
# name => $self->user, |
|
163
|
|
|
|
|
|
|
# domain => {id => "default"}, |
|
164
|
|
|
|
|
|
|
# password => $self->password, |
|
165
|
|
|
|
|
|
|
# } |
|
166
|
|
|
|
|
|
|
# } |
|
167
|
|
|
|
|
|
|
# } |
|
168
|
|
|
|
|
|
|
# } |
|
169
|
|
|
|
|
|
|
#}; |
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
sub auth { |
|
173
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
174
|
0
|
|
|
|
|
|
croak "not implemented yet......"; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
1; |