line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webservice::OVH::Cloud::Project::IP::Failover; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=encoding utf-8 |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Webservice::OVH::Cloud::Project::IP::Failover |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Webservice::OVH; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $ovh = Webservice::OVH->new_from_json("credentials.json"); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $projects = $ovh->cloud->projects; |
16
|
|
|
|
|
|
|
my $example_project = $projects->[0]; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $failover_ips = $project->ip->failovers; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
foreach my $ip (@$failover_ips) { |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
print $ip->routed_to; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 DESCRIPTION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Gives access to failover ip functionality. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
36
|
|
|
36
|
|
253
|
use strict; |
|
36
|
|
|
|
|
83
|
|
|
36
|
|
|
|
|
1062
|
|
34
|
36
|
|
|
36
|
|
191
|
use warnings; |
|
36
|
|
|
|
|
77
|
|
|
36
|
|
|
|
|
1036
|
|
35
|
36
|
|
|
36
|
|
186
|
use Carp qw{ carp croak }; |
|
36
|
|
|
|
|
83
|
|
|
36
|
|
|
|
|
29638
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = 0.46; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 _new |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Internal Method to create the SSH object. |
42
|
|
|
|
|
|
|
This method is not ment to be called directly. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=over |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=item * Parameter: %params - key => value |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud::Project::IP::Failover> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=item * Synopsis: Webservice::OVH::Cloud::Project::IP::Failover->_new(wrapper => $ovh_api_wrapper, project => $project, module => $module, id => $id ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=back |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _new { |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
|
|
my ( $class, %params ) = @_; |
59
|
|
|
|
|
|
|
|
60
|
0
|
0
|
|
|
|
|
die "Missing id" unless $params{id}; |
61
|
0
|
0
|
|
|
|
|
die "Missing project" unless $params{project}; |
62
|
0
|
0
|
|
|
|
|
die "Missing module" unless $params{module}; |
63
|
0
|
0
|
|
|
|
|
die "Missing wrapper" unless $params{wrapper}; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $api_wrapper = $params{wrapper}; |
66
|
0
|
|
|
|
|
|
my $module = $params{module}; |
67
|
0
|
|
|
|
|
|
my $project = $params{project}; |
68
|
0
|
|
|
|
|
|
my $failover_id = $params{id}; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
my $self = bless { module => $module, _api_wrapper => $api_wrapper, _project => $project, _id => $failover_id, _properties => {} }, $class; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->properties; |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $self; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 id |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Returns the api id |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * Return: VALUE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * Synopsis: my $id = $failover_ip->id; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=back |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub id { |
92
|
|
|
|
|
|
|
|
93
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
return $self->{_id}; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 project |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Root Project. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * Return: L<Webservice::OVH::Cloud::Project> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item * Synopsis: my $project = $failover_ip->project; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub project { |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
115
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
return $self->{_propject}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 properties |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the raw properties as a hash. |
122
|
|
|
|
|
|
|
This is the original return value of the web-api. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * Return: HASH |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * Synopsis: my $properties = $failover->properties; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=cut |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub properties { |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
137
|
|
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
139
|
0
|
|
|
|
|
|
my $failover_id = $self->id; |
140
|
0
|
|
|
|
|
|
my $project_id = $self->project->id; |
141
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'get', path => "/cloud/project/$project_id/ip/failover/$failover_id", noSignature => 0 ); |
142
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
143
|
0
|
|
|
|
|
|
$self->{_properties} = $response->content; |
144
|
0
|
|
|
|
|
|
return $self->{_properties}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 continent_code |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Exposed property value. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * Return: VALUE |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * Synopsis: my $continent_code = $failover_ip->continent_code; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub continent_code { |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
return $self->{_properties}->{continentCode}; |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 progress |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Exposed property value. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=over |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item * Return: VALUE |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=item * Synopsis: my $progress = $failover_ip->progress; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=back |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
sub progress { |
183
|
|
|
|
|
|
|
|
184
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
return $self->{_properties}->{progress}; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head2 status |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Exposed property value. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=over |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item * Return: VALUE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=item * Synopsis: my $status = $failover_ip->status; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=back |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=cut |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub status { |
204
|
|
|
|
|
|
|
|
205
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
206
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
return $self->{_properties}->{status}; |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head2 ip |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
Exposed property value. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * Return: VALUE |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=item * Synopsis: my $ip = $failover_ip->ip; |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=back |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub ip { |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
227
|
|
|
|
|
|
|
|
228
|
0
|
|
|
|
|
|
return $self->{_properties}->{ip}; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 routed_to |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Exposed property value. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=over |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item * Return: VALUE |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * Synopsis: my $routed_to = $failover_ip->routed_to; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=back |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=cut |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
sub routed_to { |
246
|
|
|
|
|
|
|
|
247
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
248
|
|
|
|
|
|
|
|
249
|
0
|
|
|
|
|
|
return $self->{_properties}->{routedTo}; |
250
|
|
|
|
|
|
|
} |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=head2 sub_type |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Exposed property value. |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=over |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=item * Return: VALUE |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=item * Synopsis: my $sub_type = $failover_ip->sub_type; |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=back |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=cut |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
sub sub_type { |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
269
|
|
|
|
|
|
|
|
270
|
0
|
|
|
|
|
|
return $self->{_properties}->{subType}; |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head2 block |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Exposed property value. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=over |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item * Return: VALUE |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item * Synopsis: my $block = $failover_ip->block; |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=back |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=cut |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub block { |
288
|
|
|
|
|
|
|
|
289
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
290
|
|
|
|
|
|
|
|
291
|
0
|
|
|
|
|
|
return $self->{_properties}->{block}; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=head2 geoloc |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
Exposed property value. |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=over |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=item * Return: VALUE |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=item * Synopsis: my $geoloc = $failover_ip->geoloc; |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=back |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=cut |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub geoloc { |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
return $self->{_properties}->{geoloc}; |
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
|
315
|
|
|
|
|
|
|
=head2 attach |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
Attach failover ip to an instance. |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
=over |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=item * Parameter: instance_id - instance id |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
=item * Synopsis: $failover_ip->attach($instace_id); |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=back |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=cut |
328
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
sub attach { |
330
|
|
|
|
|
|
|
|
331
|
0
|
|
|
0
|
1
|
|
my ( $self, $instance_id ) = @_; |
332
|
|
|
|
|
|
|
|
333
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
334
|
0
|
|
|
|
|
|
my $failover_id = $self->id; |
335
|
0
|
|
|
|
|
|
my $project_id = $self->project->id; |
336
|
|
|
|
|
|
|
|
337
|
0
|
0
|
|
|
|
|
croak "Missing instance_id" unless $instance_id; |
338
|
|
|
|
|
|
|
|
339
|
0
|
|
|
|
|
|
my $response = $api->rawCall( method => 'post', path => "/cloud/project/$project_id/ip/failover/$failover_id/attach", body => { instanceId => $instance_id }, noSignature => 0 ); |
340
|
0
|
0
|
|
|
|
|
croak $response->error if $response->error; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
1; |