File Coverage

blib/lib/Linux/LVM2/LV.pm
Criterion Covered Total %
statement 11 13 84.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 16 18 88.8


line stmt bran cond sub pod time code
1             package Linux::LVM2::LV;
2             {
3             $Linux::LVM2::LV::VERSION = '0.14';
4             }
5             BEGIN {
6 1     1   5197 $Linux::LVM2::LV::AUTHORITY = 'cpan:TEX';
7             }
8             # ABSTRACT: a class representing a LV in a Linux LVM2
9              
10 1     1   33 use 5.010_000;
  1         5  
  1         44  
11 1     1   7 use mro 'c3';
  1         3  
  1         8  
12 1     1   33 use feature ':5.10';
  1         3  
  1         131  
13              
14 1     1   559 use Moose;
  0            
  0            
15             use namespace::autoclean;
16              
17             # use IO::Handle;
18             # use autodie;
19             # use MooseX::Params::Validate;
20              
21             has 'name' => (
22             'is' => 'ro',
23             'isa' => 'Str',
24             'required' => 1,
25             );
26              
27             has 'vg' => (
28             'is' => 'ro',
29             'isa' => 'Linux::LVM2::VG',
30             'required' => 1,
31             'weak_ref' => 1,
32             );
33              
34             has 'access' => (
35             'is' => 'rw',
36             'isa' => 'Int',
37             'required' => 1,
38             );
39              
40             has 'status' => (
41             'is' => 'rw',
42             'isa' => 'Int',
43             'required' => 1,
44             );
45              
46             has 'intlvnum' => (
47             'is' => 'rw',
48             'isa' => 'Int',
49             'required' => 1,
50             );
51              
52             has 'opencount' => (
53             'is' => 'rw',
54             'isa' => 'Int',
55             'required' => 1,
56             );
57              
58             has 'lvsize' => (
59             'is' => 'rw',
60             'isa' => 'Int',
61             'required' => 1,
62             );
63              
64             has 'leassoc' => (
65             'is' => 'rw',
66             'isa' => 'Int',
67             'required' => 1,
68             );
69              
70             has 'lealloc' => (
71             'is' => 'rw',
72             'isa' => 'Int',
73             'required' => 1,
74             );
75              
76             has 'allocpol' => (
77             'is' => 'rw',
78             'isa' => 'Int',
79             'required' => 1,
80             );
81              
82             has 'rasect' => (
83             'is' => 'rw',
84             'isa' => 'Int',
85             'required' => 1,
86             );
87              
88             has 'majornum' => (
89             'is' => 'rw',
90             'isa' => 'Int',
91             'required' => 1,
92             );
93              
94             has 'minornum' => (
95             'is' => 'rw',
96             'isa' => 'Int',
97             'required' => 1,
98             );
99              
100             has 'origin' => (
101             'is' => 'rw',
102             'isa' => 'Linux::LVM2::LV',
103             );
104              
105             has 'snap_pc' => (
106             'is' => 'rw',
107             'isa' => 'Int',
108             );
109              
110             has 'move' => (
111             'is' => 'rw',
112             'isa' => 'Str', # ???
113             );
114              
115             has 'log' => (
116             'is' => 'rw',
117             'isa' => 'Str', # ???
118             );
119              
120             has 'copy_pc' => (
121             'is' => 'rw',
122             'isa' => 'Int',
123             );
124              
125             has 'convert' => (
126             'is' => 'rw',
127             'isa' => 'Str', # ???
128             );
129              
130             has 'mount_point' => (
131             'is' => 'rw',
132             'isa' => 'Str',
133             'default' => q{},
134             );
135              
136             has 'fs_type' => (
137             'is' => 'rw',
138             'isa' => 'Str',
139             );
140              
141             has 'fs_options' => (
142             'is' => 'rw',
143             'isa' => 'Str',
144             );
145              
146             sub BUILD {
147             my $self = shift;
148              
149             $self->vg()->lvs()->{ $self->name() } = $self;
150              
151             return 1;
152             }
153              
154             sub full_path {
155             my $self = shift;
156              
157             return '/dev/' . $self->vg()->name() . '/' . $self->name();
158             }
159              
160             sub mapper_path {
161             my $self = shift;
162              
163             my $vg = $self->vg()->name();
164             $vg =~ s/(?<!-)-(?!-)/--/;
165             my $lv = $self->name();
166             $lv =~ s/(?<!-)-(?!-)/--/;
167             return '/dev/mapper/' . $vg . '-' . $lv;
168             }
169              
170             sub valid {
171             my $self = shift;
172             $self->vg()->update();
173             if ( $self->snap_pc() < 100 ) {
174             return 1;
175             }
176             else {
177             return;
178             }
179             }
180              
181             no Moose;
182             __PACKAGE__->meta->make_immutable;
183              
184             1;
185              
186             __END__
187              
188             =pod
189              
190             =encoding utf-8
191              
192             =head1 NAME
193              
194             Linux::LVM2::LV - a class representing a LV in a Linux LVM2
195              
196             =head1 SYNOPSIS
197              
198             Instances of this class are usually created by Linux::LVM2::_find_vgs.
199              
200             =head1 ATTRIBUTES
201              
202             =head2 name
203              
204             UNDOCUMENTED
205              
206             =head2 vg
207              
208             UNDOCUMENTED
209              
210             =head2 access
211              
212             UNDOCUMENTED
213              
214             =head2 status
215              
216             UNDOCUMENTED
217              
218             =head2 intlvnum
219              
220             UNDOCUMENTED
221              
222             =head2 opencount
223              
224             UNDOCUMENTED
225              
226             =head2 lvsize
227              
228             UNDOCUMENTED
229              
230             =head2 leassoc
231              
232             UNDOCUMENTED
233              
234             =head2 lealloc
235              
236             UNDOCUMENTED
237              
238             =head2 allocpol
239              
240             UNDOCUMENTED
241              
242             =head2 rasect
243              
244             UNDOCUMENTED
245              
246             =head2 majornum
247              
248             UNDOCUMENTED
249              
250             =head2 minornum
251              
252             UNDOCUMENTED
253              
254             =head2 origin
255              
256             UNDOCUMENTED
257              
258             =head2 snap_pc
259              
260             UNDOCUMENTED
261              
262             =head2 move
263              
264             UNDOCUMENTED
265              
266             =head2 log
267              
268             UNDOCUMENTED
269              
270             =head2 copy_pc
271              
272             UNDOCUMENTED
273              
274             =head2 convert
275              
276             UNDOCUMENTED
277              
278             =head2 mount_point
279              
280             UNDOCUMENTED
281              
282             =head2 fs_type
283              
284             UNDOCUMENTED
285              
286             =head2 fs_options
287              
288             UNDOCUMENTED
289              
290             =head1 METHODS
291              
292             =head2 BUILD
293              
294             Invoked by Moose on construction. Sets a reference to this object in our VG.
295              
296             =head2 full_path
297              
298             Returns the /dev/<vg>/<lv> path to the LV.
299              
300             =head2 mapper_path
301              
302             Returns the /dev/mapper/.. path to the LV.
303              
304             =head2 valid
305              
306             Returns true if the snapshot percentage of this LV is below 100%.
307              
308             =head1 NAME
309              
310             Linux::LVM2::LV - Model a logical-volume
311              
312             =head1 AUTHOR
313              
314             Dominik Schulz <dominik.schulz@gauner.org>
315              
316             =head1 COPYRIGHT AND LICENSE
317              
318             This software is copyright (c) 2012 by Dominik Schulz.
319              
320             This is free software; you can redistribute it and/or modify it under
321             the same terms as the Perl 5 programming language system itself.
322              
323             =cut