line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::Base; |
2
|
6
|
|
|
6
|
|
56706
|
use Carp; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
306
|
|
3
|
6
|
|
|
6
|
|
370
|
use Mouse; |
|
6
|
|
|
|
|
21695
|
|
|
6
|
|
|
|
|
36
|
|
4
|
6
|
|
|
6
|
|
3014
|
use JSON; |
|
6
|
|
|
|
|
9275
|
|
|
6
|
|
|
|
|
54
|
|
5
|
6
|
|
|
6
|
|
3045
|
use Furl; |
|
6
|
|
|
|
|
131553
|
|
|
6
|
|
|
|
|
187
|
|
6
|
6
|
|
|
6
|
|
433
|
use Data::Validator; |
|
6
|
|
|
|
|
2337
|
|
|
6
|
|
|
|
|
162
|
|
7
|
6
|
|
|
6
|
|
2585
|
use namespace::clean -except => 'meta'; |
|
6
|
|
|
|
|
74954
|
|
|
6
|
|
|
|
|
34
|
|
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
|
4174
|
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
|
|
|
|
|
44
|
region => { isa => 'Str', default => undef }, |
42
|
|
|
|
|
|
|
); |
43
|
1
|
|
|
|
|
195
|
my $args = $rule->validate(@_); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
68
|
my $found_endpoint; |
46
|
1
|
|
|
|
|
1
|
LOOP: foreach my $service_catelog ( @{ $self->service_catalog } ) { |
|
1
|
|
|
|
|
4
|
|
47
|
1
|
50
|
|
|
|
4
|
if ( $args->{service_type} eq $service_catelog->{type} ) { |
48
|
1
|
|
|
|
|
2
|
foreach my $endpoint ( @{ $service_catelog->{endpoints} } ) { |
|
1
|
|
|
|
|
3
|
|
49
|
1
|
50
|
|
|
|
3
|
if ( exists $endpoint->{ $args->{endpoint_type} } ) { |
50
|
|
|
|
|
|
|
# check if the region matches or if there is no prefered region |
51
|
1
|
50
|
33
|
|
|
4
|
if ( !$args->{region} or $args->{region} eq $endpoint->{region} ) { |
52
|
1
|
|
|
|
|
3
|
$found_endpoint = $endpoint; |
53
|
|
|
|
|
|
|
# we found it, stop searching |
54
|
1
|
|
|
|
|
3
|
last LOOP; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
1
|
50
|
|
|
|
3
|
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
|
|
3995
|
use Carp; |
|
6
|
|
|
|
|
52
|
|
|
6
|
|
|
|
|
358
|
|
68
|
6
|
|
|
6
|
|
45
|
use JSON; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
81
|
|
69
|
6
|
|
|
6
|
|
683
|
use Mouse; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
55
|
|
70
|
6
|
|
|
6
|
|
2555
|
use namespace::clean -except => 'meta'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
21
|
|
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 $url = $res->header('X-Storage-Url'); |
98
|
0
|
|
|
|
|
|
$self->auth_token( $res->header('X-Auth-Token') ); |
99
|
0
|
|
|
|
|
|
$self->service_catalog( |
100
|
|
|
|
|
|
|
[ |
101
|
|
|
|
|
|
|
{ |
102
|
|
|
|
|
|
|
type => 'object-store', |
103
|
|
|
|
|
|
|
endpoints => [ { endpoint_type => 'publicURL', publicURL => $url } ] |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
] |
106
|
|
|
|
|
|
|
); |
107
|
0
|
|
|
|
|
|
return $self->auth_token(); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::V2_0; |
111
|
6
|
|
|
6
|
|
3089
|
use Carp; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
296
|
|
112
|
6
|
|
|
6
|
|
30
|
use JSON; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
26
|
|
113
|
6
|
|
|
6
|
|
476
|
use Mouse; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
21
|
|
114
|
6
|
|
|
6
|
|
1810
|
use namespace::clean -except => 'meta'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
19
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
extends 'Net::OpenStack::Swift::InnerKeystone::Base'; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub get_auth_params { |
119
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
120
|
|
|
|
|
|
|
return { |
121
|
0
|
|
|
|
|
|
auth => { |
122
|
|
|
|
|
|
|
tenantName => $self->tenant_name, |
123
|
|
|
|
|
|
|
passwordCredentials => { |
124
|
|
|
|
|
|
|
username => $self->user, |
125
|
|
|
|
|
|
|
password => $self->password, |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub auth { |
132
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
my $res = $self->agent->post( |
134
|
|
|
|
|
|
|
$self->auth_url . "/tokens", |
135
|
|
|
|
|
|
|
[ 'Content-Type' => 'application/json' ], |
136
|
|
|
|
|
|
|
to_json( $self->get_auth_params ), |
137
|
|
|
|
|
|
|
); |
138
|
0
|
0
|
|
|
|
|
croak "authorization failed: " . $res->status_line unless $res->is_success; |
139
|
0
|
|
|
|
|
|
my $body_params = from_json( $res->content ); |
140
|
0
|
|
|
|
|
|
$self->auth_token( $body_params->{access}->{token}->{id} ); |
141
|
0
|
|
|
|
|
|
$self->service_catalog( $body_params->{access}->{serviceCatalog} ); |
142
|
0
|
|
|
|
|
|
return $self->auth_token(); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
package Net::OpenStack::Swift::InnerKeystone::V3_0; |
146
|
6
|
|
|
6
|
|
2932
|
use Carp; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
334
|
|
147
|
6
|
|
|
6
|
|
32
|
use JSON; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
33
|
|
148
|
6
|
|
|
6
|
|
468
|
use Mouse; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
33
|
|
149
|
6
|
|
|
6
|
|
1799
|
use namespace::clean -except => 'meta'; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
19
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
extends 'Net::OpenStack::Swift::InnerKeystone::Base'; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
0
|
0
|
|
sub get_auth_params { |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#return { |
156
|
|
|
|
|
|
|
# auth => { |
157
|
|
|
|
|
|
|
# identity => { |
158
|
|
|
|
|
|
|
# methods => ['password'], |
159
|
|
|
|
|
|
|
# password => { |
160
|
|
|
|
|
|
|
# user => { |
161
|
|
|
|
|
|
|
# name => $self->user, |
162
|
|
|
|
|
|
|
# domain => {id => "default"}, |
163
|
|
|
|
|
|
|
# password => $self->password, |
164
|
|
|
|
|
|
|
# } |
165
|
|
|
|
|
|
|
# } |
166
|
|
|
|
|
|
|
# } |
167
|
|
|
|
|
|
|
# } |
168
|
|
|
|
|
|
|
#}; |
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub auth { |
172
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
173
|
0
|
|
|
|
|
|
croak "not implemented yet......"; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
1; |