line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Linode; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006000; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
893
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
82
|
|
9
|
1
|
|
|
1
|
|
9
|
use List::Util qw(first); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
84
|
|
10
|
1
|
|
|
1
|
|
5
|
use WebService::Linode::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
473
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.25'; |
13
|
|
|
|
|
|
|
our @ISA = ("WebService::Linode::Base"); |
14
|
|
|
|
|
|
|
our $AUTOLOAD; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my %validation = ( |
17
|
|
|
|
|
|
|
account => { |
18
|
|
|
|
|
|
|
estimateinvoice => [ [ 'mode' ], [qw( linodeid paymentterm planid )] ], |
19
|
|
|
|
|
|
|
info => [ [], [] ], |
20
|
|
|
|
|
|
|
paybalance => [ [], [] ], |
21
|
|
|
|
|
|
|
updatecard => [ [qw( ccexpmonth ccexpyear ccnumber )], [] ], |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
api => { |
24
|
|
|
|
|
|
|
spec => [ [], [] ], |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
avail => { |
27
|
|
|
|
|
|
|
datacenters => [ [], [] ], |
28
|
|
|
|
|
|
|
distributions => [ [], [ 'distributionid' ] ], |
29
|
|
|
|
|
|
|
kernels => [ [], [ 'isxen', 'kernelid' ] ], |
30
|
|
|
|
|
|
|
linodeplans => [ [], [ 'planid' ] ], |
31
|
|
|
|
|
|
|
nodebalancers => [ [], [] ], |
32
|
|
|
|
|
|
|
stackscripts => [ [], [qw( distributionid distributionvendor keywords )] ], |
33
|
|
|
|
|
|
|
}, |
34
|
|
|
|
|
|
|
domain => { |
35
|
|
|
|
|
|
|
create => [ [ 'domain', 'type' ], [qw( axfr_ips description expire_sec lpm_displaygroup master_ips refresh_sec retry_sec soa_email status ttl_sec )] ], |
36
|
|
|
|
|
|
|
delete => [ [ 'domainid' ], [] ], |
37
|
|
|
|
|
|
|
list => [ [], [ 'domainid' ] ], |
38
|
|
|
|
|
|
|
update => [ [ 'domainid' ], [qw( axfr_ips description domain expire_sec lpm_displaygroup master_ips refresh_sec retry_sec soa_email status ttl_sec type )] ], |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
domain_resource => { |
41
|
|
|
|
|
|
|
create => [ [ 'domainid', 'type' ], [qw( name port priority protocol target ttl_sec weight )] ], |
42
|
|
|
|
|
|
|
delete => [ [ 'domainid', 'resourceid' ], [] ], |
43
|
|
|
|
|
|
|
list => [ [ 'domainid' ], [ 'resourceid' ] ], |
44
|
|
|
|
|
|
|
update => [ [ 'resourceid' ], [qw( domainid name port priority protocol target ttl_sec weight )] ], |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
image => { |
47
|
|
|
|
|
|
|
delete => [ [ 'imageid' ], [] ], |
48
|
|
|
|
|
|
|
list => [ [], [ 'imageid', 'pending' ] ], |
49
|
|
|
|
|
|
|
}, |
50
|
|
|
|
|
|
|
linode => { |
51
|
|
|
|
|
|
|
boot => [ [ 'linodeid' ], [ 'configid' ] ], |
52
|
|
|
|
|
|
|
clone => [ [qw( datacenterid linodeid planid )], [ 'paymentterm' ] ], |
53
|
|
|
|
|
|
|
create => [ [ 'datacenterid', 'planid' ], [ 'paymentterm' ] ], |
54
|
|
|
|
|
|
|
delete => [ [ 'linodeid' ], [ 'skipchecks' ] ], |
55
|
|
|
|
|
|
|
list => [ [], [ 'linodeid' ] ], |
56
|
|
|
|
|
|
|
mutate => [ [ 'linodeid' ], [] ], |
57
|
|
|
|
|
|
|
reboot => [ [ 'linodeid' ], [ 'configid' ] ], |
58
|
|
|
|
|
|
|
resize => [ [ 'linodeid', 'planid' ], [] ], |
59
|
|
|
|
|
|
|
shutdown => [ [ 'linodeid' ], [] ], |
60
|
|
|
|
|
|
|
update => [ [ 'linodeid' ], [qw( alert_bwin_enabled alert_bwin_threshold alert_bwout_enabled alert_bwout_threshold alert_bwquota_enabled alert_bwquota_threshold alert_cpu_enabled alert_cpu_threshold alert_diskio_enabled alert_diskio_threshold backupweeklyday backupwindow label lpm_displaygroup ms_ssh_disabled ms_ssh_ip ms_ssh_port ms_ssh_user watchdog )] ], |
61
|
|
|
|
|
|
|
webconsoletoken => [ [ 'linodeid' ], [] ], |
62
|
|
|
|
|
|
|
}, |
63
|
|
|
|
|
|
|
linode_config => { |
64
|
|
|
|
|
|
|
create => [ [qw( kernelid label linodeid )], [qw( comments devtmpfs_automount disklist helper_depmod helper_disableupdatedb helper_network helper_xen ramlimit rootdevicecustom rootdevicenum rootdevicero runlevel )] ], |
65
|
|
|
|
|
|
|
delete => [ [ 'configid', 'linodeid' ], [] ], |
66
|
|
|
|
|
|
|
list => [ [ 'linodeid' ], [ 'configid' ] ], |
67
|
|
|
|
|
|
|
update => [ [ 'configid' ], [qw( comments devtmpfs_automount disklist helper_depmod helper_disableupdatedb helper_network helper_xen kernelid label linodeid ramlimit rootdevicecustom rootdevicenum rootdevicero runlevel )] ], |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
linode_disk => { |
70
|
|
|
|
|
|
|
create => [ [qw( label linodeid size type )], [qw( fromdistributionid isreadonly rootpass rootsshkey )] ], |
71
|
|
|
|
|
|
|
createfromdistribution => [ [qw( distributionid label linodeid rootpass size )], [ 'rootsshkey' ] ], |
72
|
|
|
|
|
|
|
createfromimage => [ [ 'imageid', 'linodeid' ], [qw( label rootpass rootsshkey size )] ], |
73
|
|
|
|
|
|
|
createfromstackscript => [ [qw( distributionid label linodeid rootpass size stackscriptid stackscriptudfresponses )], [ 'rootsshkey' ] ], |
74
|
|
|
|
|
|
|
delete => [ [ 'diskid', 'linodeid' ], [] ], |
75
|
|
|
|
|
|
|
duplicate => [ [ 'diskid', 'linodeid' ], [] ], |
76
|
|
|
|
|
|
|
imagize => [ [ 'diskid', 'linodeid' ], [ 'description', 'label' ] ], |
77
|
|
|
|
|
|
|
list => [ [ 'linodeid' ], [ 'diskid' ] ], |
78
|
|
|
|
|
|
|
resize => [ [qw( diskid linodeid size )], [] ], |
79
|
|
|
|
|
|
|
update => [ [ 'diskid' ], [qw( isreadonly label linodeid )] ], |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
linode_ip => { |
82
|
|
|
|
|
|
|
addprivate => [ [ 'linodeid' ], [] ], |
83
|
|
|
|
|
|
|
addpublic => [ [ 'linodeid' ], [] ], |
84
|
|
|
|
|
|
|
list => [ [ 'linodeid' ], [ 'ipaddressid' ] ], |
85
|
|
|
|
|
|
|
setrdns => [ [ 'hostname', 'ipaddressid' ], [] ], |
86
|
|
|
|
|
|
|
swap => [ [ 'ipaddressid' ], [ 'tolinodeid', 'withipaddressid' ] ], |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
linode_job => { |
89
|
|
|
|
|
|
|
list => [ [ 'linodeid' ], [ 'jobid', 'pendingonly' ] ], |
90
|
|
|
|
|
|
|
}, |
91
|
|
|
|
|
|
|
nodebalancer => { |
92
|
|
|
|
|
|
|
create => [ [ 'datacenterid' ], [qw( clientconnthrottle label paymentterm )] ], |
93
|
|
|
|
|
|
|
delete => [ [ 'nodebalancerid' ], [] ], |
94
|
|
|
|
|
|
|
list => [ [], [ 'nodebalancerid' ] ], |
95
|
|
|
|
|
|
|
update => [ [ 'nodebalancerid' ], [ 'clientconnthrottle', 'label' ] ], |
96
|
|
|
|
|
|
|
}, |
97
|
|
|
|
|
|
|
nodebalancer_config => { |
98
|
|
|
|
|
|
|
create => [ [ 'nodebalancerid' ], [qw( algorithm check check_attempts check_body check_interval check_path check_timeout port protocol ssl_cert ssl_key stickiness )] ], |
99
|
|
|
|
|
|
|
delete => [ [ 'configid', 'nodebalancerid' ], [] ], |
100
|
|
|
|
|
|
|
list => [ [ 'nodebalancerid' ], [ 'configid' ] ], |
101
|
|
|
|
|
|
|
update => [ [ 'configid' ], [qw( algorithm check check_attempts check_body check_interval check_path check_timeout port protocol ssl_cert ssl_key stickiness )] ], |
102
|
|
|
|
|
|
|
}, |
103
|
|
|
|
|
|
|
nodebalancer_node => { |
104
|
|
|
|
|
|
|
create => [ [qw( address configid label )], [ 'mode', 'weight' ] ], |
105
|
|
|
|
|
|
|
delete => [ [ 'nodeid' ], [] ], |
106
|
|
|
|
|
|
|
list => [ [ 'configid' ], [ 'nodeid' ] ], |
107
|
|
|
|
|
|
|
update => [ [ 'nodeid' ], [qw( address label mode weight )] ], |
108
|
|
|
|
|
|
|
}, |
109
|
|
|
|
|
|
|
stackscript => { |
110
|
|
|
|
|
|
|
create => [ [qw( distributionidlist label script )], [qw( description ispublic rev_note )] ], |
111
|
|
|
|
|
|
|
delete => [ [ 'stackscriptid' ], [] ], |
112
|
|
|
|
|
|
|
list => [ [], [ 'stackscriptid' ] ], |
113
|
|
|
|
|
|
|
update => [ [ 'stackscriptid' ], [qw( description distributionidlist ispublic label rev_note script )] ], |
114
|
|
|
|
|
|
|
}, |
115
|
|
|
|
|
|
|
test => { |
116
|
|
|
|
|
|
|
echo => [ [], [] ], |
117
|
|
|
|
|
|
|
}, |
118
|
|
|
|
|
|
|
user => { |
119
|
|
|
|
|
|
|
getapikey => [ [ 'password', 'username' ], [qw( expires label token )] ], |
120
|
|
|
|
|
|
|
}, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub AUTOLOAD { |
124
|
0
|
|
|
0
|
|
|
( my $name = $AUTOLOAD ) =~ s/.+:://; |
125
|
0
|
0
|
|
|
|
|
return if $name eq 'DESTROY'; |
126
|
0
|
0
|
|
|
|
|
if ( $name =~ m/^(QUEUE_)?(.*?)_([^_]+)$/ ) { |
127
|
0
|
|
|
|
|
|
my ( $queue, $thing, $action ) = ( $1, $2, $3 ); |
128
|
0
|
0
|
0
|
|
|
|
if ( exists $validation{$thing} && exists $validation{$thing}{$action} ) |
129
|
1
|
|
|
1
|
|
5
|
{ no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
458
|
|
130
|
0
|
|
|
|
|
|
*{$AUTOLOAD} = sub { |
131
|
0
|
|
|
0
|
|
|
my ( $self, %args ) = @_; |
132
|
0
|
|
|
|
|
|
for my $req ( @{ $validation{$thing}{$action}[0] } ) { |
|
0
|
|
|
|
|
|
|
133
|
0
|
0
|
|
|
|
|
if ( !exists $args{$req} ) { |
134
|
0
|
|
|
|
|
|
carp |
135
|
|
|
|
|
|
|
"Missing required argument $req for ${thing}_${action}"; |
136
|
0
|
|
|
|
|
|
return; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
} |
139
|
0
|
|
|
|
|
|
for my $given ( keys %args ) { |
140
|
0
|
0
|
|
|
|
|
if (!first { $_ eq $given } |
|
0
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
@{ $validation{$thing}{$action}[0] }, |
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
@{ $validation{$thing}{$action}[1] } ) |
143
|
0
|
|
|
|
|
|
{ carp "Unknown argument $given for ${thing}_${action}"; |
144
|
0
|
|
|
|
|
|
return; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
} |
147
|
0
|
|
|
|
|
|
( my $apiAction = "${thing}_${action}" ) =~ s/_/./g; |
148
|
0
|
0
|
|
|
|
|
return $self->queue_request( api_action => $apiAction, %args ) if $queue; |
149
|
0
|
|
|
|
|
|
my $data = $self->do_request( api_action => $apiAction, %args ); |
150
|
0
|
0
|
|
|
|
|
return [ map { $self->_lc_keys($_) } @$data ] |
|
0
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
if ref $data eq 'ARRAY'; |
152
|
0
|
0
|
|
|
|
|
return $self->_lc_keys($data) if ref $data eq 'HASH'; |
153
|
0
|
|
|
|
|
|
return $data; |
154
|
0
|
|
|
|
|
|
}; |
155
|
0
|
|
|
|
|
|
goto &{$AUTOLOAD}; |
|
0
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
0
|
|
|
|
|
|
carp "Can't call ${thing}_${action}"; |
159
|
0
|
|
|
|
|
|
return; |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
return; |
162
|
|
|
|
|
|
|
} |
163
|
0
|
|
|
|
|
|
croak "Undefined subroutine \&$AUTOLOAD called"; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
sub send_queued_requests { |
167
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
168
|
0
|
|
|
|
|
|
my $items = shift; |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
if ( $self->list_queue == 0 ) { |
171
|
0
|
|
|
|
|
|
$self->_error( -1, "No queued items to send" ); |
172
|
0
|
|
|
|
|
|
return; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
my @responses; |
176
|
0
|
|
|
|
|
|
for my $data ( $self->process_queue( $items ) ) { |
177
|
0
|
0
|
|
|
|
|
if ( ref $data eq 'ARRAY' ) { |
|
|
0
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
push @responses, [ map { $self->_lc_keys($_) } @$data ]; |
|
0
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
} elsif( ref $data eq 'HASH' ) { |
180
|
0
|
|
|
|
|
|
push @responses, $self->_lc_keys($data); |
181
|
|
|
|
|
|
|
} else { |
182
|
0
|
|
|
|
|
|
push @responses, $data; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
return @responses; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
'mmm, cake'; |
190
|
|
|
|
|
|
|
__END__ |