line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OpenStack::Client; |
2
|
|
|
|
|
|
|
$Net::OpenStack::Client::VERSION = '0.1.4'; |
3
|
7
|
|
|
7
|
|
402902
|
use strict; |
|
7
|
|
|
|
|
41
|
|
|
7
|
|
|
|
|
207
|
|
4
|
7
|
|
|
7
|
|
36
|
use warnings; |
|
7
|
|
|
|
|
12
|
|
|
7
|
|
|
|
|
197
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
|
|
37
|
use parent qw( |
7
|
|
|
|
|
|
|
Net::OpenStack::Client::API |
8
|
|
|
|
|
|
|
Net::OpenStack::Client::Auth |
9
|
|
|
|
|
|
|
Net::OpenStack::Client::Base |
10
|
|
|
|
|
|
|
Net::OpenStack::Client::REST |
11
|
7
|
|
|
7
|
|
44
|
); |
|
7
|
|
|
|
|
10
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: OpenStack REST API client |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Net::OpenStack::Client |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Example usage: |
22
|
|
|
|
|
|
|
use Net::OpenStack::Client; |
23
|
|
|
|
|
|
|
... |
24
|
|
|
|
|
|
|
my $cl = Net::OpenStack::Client->new(openrc => '/home/admin/.openrc'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
For basic reporting: |
27
|
|
|
|
|
|
|
use Net::OpenStack::Client; |
28
|
|
|
|
|
|
|
use Log::Log4perl qw(:easy); |
29
|
|
|
|
|
|
|
Log::Log4perl->easy_init($INFO); |
30
|
|
|
|
|
|
|
... |
31
|
|
|
|
|
|
|
my $cl = Net::OpenStack::Client->new( |
32
|
|
|
|
|
|
|
openrc => '/home/admin/.openrc', |
33
|
|
|
|
|
|
|
log => Log::Log4perl->get_logger() |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
For debugging, including full JSON request / repsonse and headers (so contains sensitive data!): |
37
|
|
|
|
|
|
|
use Net::OpenStack::Client; |
38
|
|
|
|
|
|
|
use Log::Log4perl qw(:easy); |
39
|
|
|
|
|
|
|
Log::Log4perl->easy_init($DEBUG); |
40
|
|
|
|
|
|
|
... |
41
|
|
|
|
|
|
|
my $cl = Net::OpenStack::Client->new( |
42
|
|
|
|
|
|
|
openrc => '/home/admin/.openrc', |
43
|
|
|
|
|
|
|
log => Log::Log4perl->get_logger(), |
44
|
|
|
|
|
|
|
debugapi => 1 |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head2 Public methods |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=over |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item new |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
Options |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=over |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=item log |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
An instance that can be used for logging (with error/warn/info/debug methods) |
60
|
|
|
|
|
|
|
(e.g. L). |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=item debugapi |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
When true, log the request and response body and headers with debug. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=back |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
If more options are definded, e.g. C, they are passed to |
69
|
|
|
|
|
|
|
passed to L. |
70
|
|
|
|
|
|
|
(If no other options are defined, C is not called). |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# return 1 on success |
75
|
|
|
|
|
|
|
sub _initialize |
76
|
|
|
|
|
|
|
{ |
77
|
6
|
|
|
6
|
|
25
|
my ($self, %opts) = @_; |
78
|
|
|
|
|
|
|
|
79
|
6
|
|
|
|
|
44
|
$self->{log} = delete $opts{log}; |
80
|
6
|
|
|
|
|
17
|
$self->{debugapi} = delete $opts{debugapi}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Initialise the REST::Client |
83
|
6
|
|
|
|
|
45
|
$self->_new_client(); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Login, get token and gather services |
86
|
6
|
100
|
|
|
|
46
|
$self->login(%opts) if scalar keys %opts; |
87
|
|
|
|
|
|
|
|
88
|
6
|
|
|
|
|
39
|
return 1; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=pod |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=back |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |