line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# vim: set ts=3 sw=3 tw=0: |
5
|
|
|
|
|
|
|
# vim: set expandtab: |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
WebService::ProfitBricks::DataCenter - Manage DataCenter |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Manages the virtual datacenters. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use WebService::ProfitBricks qw/DataCenter/; |
18
|
|
|
|
|
|
|
WebService::ProfitBricks->auth($user, $password); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $dc = DataCenter->new(dataCenterName => "DC1", region => "EUROPE"); |
21
|
|
|
|
|
|
|
$dc->save; |
22
|
|
|
|
|
|
|
$dc->wait_for_provisioning; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $dc = DataCenter->find("DC1"); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
This class implements all methods from L and these additional ones. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over 4 |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
package WebService::ProfitBricks::DataCenter; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
1
|
|
5467
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
37
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
38
|
|
|
|
|
|
|
|
39
|
1
|
|
|
1
|
|
8
|
use Data::Dumper; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
63
|
|
40
|
1
|
|
|
1
|
|
7
|
use WebService::ProfitBricks::Class; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
89
|
|
41
|
1
|
|
|
1
|
|
5
|
use base qw(WebService::ProfitBricks); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
166
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
attrs qw/dataCenterName |
44
|
|
|
|
|
|
|
dataCenterVersion |
45
|
|
|
|
|
|
|
dataCenterId |
46
|
|
|
|
|
|
|
region |
47
|
|
|
|
|
|
|
provisioningState/; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
does find => { through => "dataCenterName" }; |
50
|
|
|
|
|
|
|
does list => { through => "getAllDataCenters" }; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
serializer "xml"; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has_many server => "WebService::ProfitBricks::Server" => { through => "servers" }; |
55
|
|
|
|
|
|
|
has_many loadBalancer => "WebService::ProfitBricks::LoadBalancer" => { through => "loadBalancers" }; |
56
|
|
|
|
|
|
|
has_many storage => "WebService::ProfitBricks::Storage" => { through => "storages" }; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=item wait_for_provisioning |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Call this function if you modified something in your virtual datacenter (like adding a new server, new storage, ...). This will block until your modification is done. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=cut |
63
|
|
|
|
|
|
|
sub wait_for_provisioning { |
64
|
|
|
|
|
|
|
my ($self) = @_; |
65
|
|
|
|
|
|
|
my $is_ready = 0; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
while($is_ready == 0) { |
68
|
|
|
|
|
|
|
$self->get_state; |
69
|
|
|
|
|
|
|
if(exists $self->{__data__}->{provisioningState} && $self->{__data__}->{provisioningState} eq "AVAILABLE") { |
70
|
|
|
|
|
|
|
$is_ready = 1; |
71
|
|
|
|
|
|
|
last; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sleep 3; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item get_state |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
This method returns the current provisioning state of your virtual datacenter. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
sub get_state { |
84
|
|
|
|
|
|
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
my $data = $self->connection->call("getDataCenterState", dataCenterId => $self->dataCenterId); |
86
|
|
|
|
|
|
|
$self->provisioningState($data); |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |