line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/bin/false |
2
|
|
|
|
|
|
|
# vim: softtabstop=2 tabstop=2 shiftwidth=2 ft=perl expandtab smarttab |
3
|
|
|
|
|
|
|
# PODNAME: Net::Proxmox::VE::Storage |
4
|
|
|
|
|
|
|
# ABSTRACT: Store object |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
60
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Net::Proxmox::VE::Storage; |
10
|
|
|
|
|
|
|
$Net::Proxmox::VE::Storage::VERSION = '0.38'; |
11
|
1
|
|
|
1
|
|
6
|
use parent 'Exporter'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
52
|
use Carp qw( croak ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
492
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our @EXPORT = qw( storages ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my $base = '/storages'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub storage { |
22
|
|
|
|
|
|
|
|
23
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
return $self->get($base); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub get_storage { |
31
|
|
|
|
|
|
|
|
32
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No storageid for get_storage()'; |
35
|
0
|
0
|
|
|
|
|
croak 'storageid must be a scalar for get_storage()' if ref $a; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
return $self->get( $base, $a ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub create_storage { |
43
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
45
|
0
|
|
|
|
|
|
my @p = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
croak 'No arguments for create_storage()' unless @p; |
48
|
0
|
|
|
|
|
|
my %args; |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
51
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for create_storage()' |
52
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
53
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else { |
56
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for create_storage()' |
57
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
58
|
0
|
|
|
|
|
|
%args = @p; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self->post( $base, \%args ) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub delete_storage { |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
69
|
0
|
0
|
|
|
|
|
my $a = shift or croak 'No argument given for delete_storage()'; |
70
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self->delete( $base, $a ); |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub update_storage { |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
0
|
1
|
|
my $self = shift or return; |
79
|
0
|
0
|
|
|
|
|
my $storageid = shift or croak 'No storageid provided for update_storage()'; |
80
|
0
|
0
|
|
|
|
|
croak 'storageid must be a scalar for update_storage()' if ref $storageid; |
81
|
0
|
|
|
|
|
|
my @p = @_; |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
croak 'No arguments for update_storage()' unless @p; |
84
|
0
|
|
|
|
|
|
my %args; |
85
|
|
|
|
|
|
|
|
86
|
0
|
0
|
|
|
|
|
if ( @p == 1 ) { |
87
|
0
|
0
|
|
|
|
|
croak 'Single argument not a hash for update_storage()' |
88
|
|
|
|
|
|
|
unless ref $a eq 'HASH'; |
89
|
0
|
|
|
|
|
|
%args = %{ $p[0] }; |
|
0
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
else { |
92
|
0
|
0
|
|
|
|
|
croak 'Odd number of arguments for update_storage()' |
93
|
|
|
|
|
|
|
if ( scalar @p % 2 != 0 ); |
94
|
0
|
|
|
|
|
|
%args = @p; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
return $self->put( $base, $storageid, \%args ); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
1; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
__END__ |