line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package VMware::vCloudDirector2; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Interface to VMWare vCloud Directory REST API |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
273822
|
use strict; |
|
4
|
|
|
|
|
30
|
|
|
4
|
|
|
|
|
105
|
|
6
|
4
|
|
|
4
|
|
17
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
165
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.106'; # VERSION |
9
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:NIGELM'; # AUTHORITY |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
1429
|
use Moose; |
|
4
|
|
|
|
|
1330074
|
|
|
4
|
|
|
|
|
25
|
|
12
|
4
|
|
|
4
|
|
28040
|
use Method::Signatures; |
|
4
|
|
|
|
|
166346
|
|
|
4
|
|
|
|
|
31
|
|
13
|
4
|
|
|
4
|
|
3242
|
use MooseX::Types::Path::Tiny qw/Path/; |
|
4
|
|
|
|
|
1406325
|
|
|
4
|
|
|
|
|
46
|
|
14
|
4
|
|
|
4
|
|
10979
|
use VMware::vCloudDirector2::API; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
166
|
|
15
|
4
|
|
|
4
|
|
40
|
use VMware::vCloudDirector2::Error; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
84
|
|
16
|
4
|
|
|
4
|
|
22
|
use VMware::vCloudDirector2::Object; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
652
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has debug => ( is => 'rw', isa => 'Bool', default => 0 ); # Defaults to no debug info |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has hostname => ( is => 'ro', isa => 'Str', required => 1 ); |
24
|
|
|
|
|
|
|
has username => ( is => 'ro', isa => 'Str', required => 1 ); |
25
|
|
|
|
|
|
|
has password => ( is => 'ro', isa => 'Str', required => 1 ); |
26
|
|
|
|
|
|
|
has orgname => ( is => 'ro', isa => 'Str', required => 1, default => 'System' ); |
27
|
|
|
|
|
|
|
has ssl_verify => ( is => 'ro', isa => 'Bool', predicate => '_has_ssl_verify' ); |
28
|
|
|
|
|
|
|
has timeout => ( is => 'rw', isa => 'Int', predicate => '_has_timeout' ); |
29
|
|
|
|
|
|
|
has ssl_ca_file => ( is => 'ro', isa => Path, coerce => 1, predicate => '_has_ssl_ca_file' ); |
30
|
|
|
|
|
|
|
has _ua => ( is => 'ro', isa => 'LWP::UserAgent', predicate => '_has_ua' ); |
31
|
|
|
|
|
|
|
has _debug_trace_directory => |
32
|
|
|
|
|
|
|
( is => 'ro', isa => Path, coerce => 1, predicate => '_has_debug_trace_directory' ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has api => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
isa => 'VMware::vCloudDirector2::API', |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
builder => '_build_api', |
39
|
|
|
|
|
|
|
handles => [qw( GET PUT POST DELETE )], |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
4
|
50
|
|
4
|
|
3256
|
method _build_api () { |
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
3
|
|
43
|
1
|
|
|
|
|
33
|
my @args = ( |
44
|
|
|
|
|
|
|
hostname => $self->hostname, |
45
|
|
|
|
|
|
|
username => $self->username, |
46
|
|
|
|
|
|
|
password => $self->password, |
47
|
|
|
|
|
|
|
orgname => $self->orgname, |
48
|
|
|
|
|
|
|
debug => $self->debug |
49
|
|
|
|
|
|
|
); |
50
|
1
|
50
|
|
|
|
28
|
push( @args, timeout => $self->timeout ) if ( $self->_has_timeout ); |
51
|
1
|
50
|
|
|
|
29
|
push( @args, ssl_verify => $self->ssl_verify ) if ( $self->_has_ssl_verify ); |
52
|
1
|
50
|
|
|
|
39
|
push( @args, ssl_ca_file => $self->ssl_ca_file ) if ( $self->_has_ssl_ca_file ); |
53
|
1
|
50
|
|
|
|
34
|
push( @args, _debug_trace_directory => $self->_debug_trace_directory ) |
54
|
|
|
|
|
|
|
if ( $self->_has_debug_trace_directory ); |
55
|
1
|
50
|
|
|
|
27
|
push( @args, _ua => $self->_ua ) if ( $self->_has_ua ); |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
32
|
return VMware::vCloudDirector2::API->new(@args); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has org_listref => ( |
64
|
|
|
|
|
|
|
is => 'ro', |
65
|
|
|
|
|
|
|
isa => 'ArrayRef[VMware::vCloudDirector2::Object]', |
66
|
|
|
|
|
|
|
lazy => 1, |
67
|
|
|
|
|
|
|
builder => '_build_org_listref', |
68
|
|
|
|
|
|
|
traits => ['Array'], |
69
|
|
|
|
|
|
|
handles => { |
70
|
|
|
|
|
|
|
org_list => 'elements', |
71
|
|
|
|
|
|
|
org_map => 'map', |
72
|
|
|
|
|
|
|
org_grep => 'grep', |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
); |
75
|
4
|
50
|
|
4
|
|
3233
|
method _build_org_listref { return [ $self->api->GET('/api/org/') ]; } |
|
1
|
|
|
1
|
|
2
|
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
4
|
|
9418
|
method query (@args) { |
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
my $uri = $self->api->query_uri->clone; |
82
|
0
|
|
|
|
|
|
$uri->query_form(@args); |
83
|
0
|
|
|
|
|
|
return $self->api->GET($uri); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# ------------------------------------------------------------------------ |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=pod |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=encoding UTF-8 |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 NAME |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
VMware::vCloudDirector2 - Interface to VMWare vCloud Directory REST API |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 VERSION |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
version 0.106 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 SYNOPSIS |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# THIS IS AT AN EARLY STAGE OF DEVELOPMENT - PROTOTYPING REALLY |
109
|
|
|
|
|
|
|
# IT MAY CHANGE DRAMATICALLY OR EAT YOUR DATA. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
use VMware::vCloudDirector2 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
my $vcd = VMware::vCloudDirector2->new( |
114
|
|
|
|
|
|
|
hostname => $host, |
115
|
|
|
|
|
|
|
username => $user, |
116
|
|
|
|
|
|
|
password => $pass, |
117
|
|
|
|
|
|
|
orgname => $org, |
118
|
|
|
|
|
|
|
ssl_verify => 0, |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
my @org_list = $vcd->org_list; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 Attributes |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head3 hostname |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Hostname of the vCloud server. Must have a vCloud instance listening for https |
127
|
|
|
|
|
|
|
on port 443. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head3 username |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Username to use to login to vCloud server. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head3 password |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Password to use to login to vCloud server. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head3 orgname |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Org name to use to login to vCloud server - this defaults to C<System>. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head3 timeout |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Command timeout in seconds. Defaults to 120. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head3 default_accept_header |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The default MIME types to accept. This is automatically set based on the |
148
|
|
|
|
|
|
|
information received back from the API versions. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head3 ssl_verify |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Whether to do standard SSL certificate verification. Defaults to set. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head3 ssl_ca_file |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
The SSL CA set to trust packaged in a file. This defaults to those set in the |
157
|
|
|
|
|
|
|
L<Mozilla::CA> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head3 debug |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Set debug level. The higher the debug level, the more chatter is exposed. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Defaults to 0 (no output) unless the environment variable C<VCLOUD_API_DEBUG> |
164
|
|
|
|
|
|
|
is set to something that is non-zero. Picked up at create time in C<BUILD()> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 Methods |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head3 org_list |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Returns a set of L<VMware::vCloudDirector2::Object> each containing one of the |
171
|
|
|
|
|
|
|
vCloud Orgs on the system (or if using this in user mode the single org you can |
172
|
|
|
|
|
|
|
see). |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head3 query |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns a L<VMware::vCloudDirector2::Object> containing the query result of the |
177
|
|
|
|
|
|
|
query against the platform. |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 DESCRIPTION |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
Thinish wrapper of the VMware vCloud Director REST API. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This differs from L<VMware::vCloudDirector> in that it uses the JSON flavoured |
184
|
|
|
|
|
|
|
version of the API, which has subtly different naming conventions (which is why |
185
|
|
|
|
|
|
|
I didn't try to make the code handle both flavours), but is much easier to work |
186
|
|
|
|
|
|
|
with when doing write operations. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
It also B<can> do write operations - as well as the other issues in |
189
|
|
|
|
|
|
|
L<VMware::vCloudDirector> it looks like the write operations - C<PUT>, C<POST> |
190
|
|
|
|
|
|
|
and C<DELETE> have never worked! |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
THIS IS AT AN EARLY STAGE OF DEVELOPMENT - PROTOTYPING REALLY - AND MAY CHANGE |
193
|
|
|
|
|
|
|
DRAMATICALLY OR EAT YOUR DATA. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
The lack of documentation reflects the stage in development... |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Nigel Metheringham <nigelm@cpan.org> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Nigel Metheringham. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
206
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=cut |