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