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