NetApp/Volume.pm

filter: Statementstmt 27.8% 93 / 334 Branchbran 32.5% 28 / 86 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 16.6% 10 / 60 Podpod 74.0% 37 / 50 totaltotal 31.2% 168 / 538 CC 49 SCAR 23.2
CC
49
Cov
28%
BUILD
30.0
get_snapshot_autodelete_option
30.0
get_language
20.0
CRAP 10.1
« NetApp/Aggregate.pm ↑ Summary NetApp/Qtree.pm »
1  
2 package NetApp::Volume;
3  
4 1 our $VERSION = '500.002';
5 1 $VERSION = eval $VERSION; ## no critic: StringyEval
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 ▶use Class::Std;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Params::Validate qw( :all );
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use Regexp::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶use NetApp::Volume::Source;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 {
19  
20 1 my %filer_of :ATTR( get => 'filer' );
21  
22 1 my %name_of :ATTR( get => 'name' );
23 1 my %state_of :ATTR;
24 1 my %status_of :ATTR;
25 1 my %options_of :ATTR;
26 1 my %source_of :ATTR( get => 'source' );
27  
28 1 my %plex_of :ATTR( get => 'plex' );
29  
30 1 my %aggregate_name_of :ATTR( get => 'aggregate_name' );
31  
32 1 my %clone_names_of :ATTR;
33 1 my %parent_name_of :ATTR( get => 'parent_name' );
34 1 my %snapshot_name_of :ATTR( get => 'snapshot_name' );
35  
36 1 my %path_of :ATTR( get => 'path' );
37  
38 0 ▶ sub BUILD {
Subroutine BUILD: not called CC=5 SCAR=34.0
Pod undocumented
39  
40 0 my ($self,$ident,$args_ref) = @_;
41  
42 0 my @args = %$args_ref;
43  
44 0 my (%args) = validate( @args, {
45 filer => { isa => 'NetApp::Filer' },
46 name => { type => SCALAR },
47 state => { type => HASHREF },
48 status => { type => HASHREF },
49 options => { type => HASHREF },
50 plex => { type => HASHREF },
51 aggregate_name => { type => SCALAR,
52 optional => 1 },
53 source => { type => HASHREF,
54 optional => 1 },
55 clone_names => { type => ARRAYREF,
56 default => [],
57 optional => 1 },
58 parent_name => { type => SCALAR,
59 optional => 1 },
60 snapshot_name => { type => SCALAR,
61 optional => 1 },
62 });
63  
64 0 $filer_of{$ident} = $args{filer};
65 0 $name_of{$ident} = $args{name};
66 0 $state_of{$ident} = $args{state};
67 0 $status_of{$ident} = $args{status};
68 0 $options_of{$ident} = $args{options};
69  
70 $plex_of{$ident} =
71 0 NetApp::Aggregate::Plex->new( $args{plex} );
72  
73 0 ▶ if ( $args{aggregate_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"aggregate_name"}) 0 0 0
74 0 $aggregate_name_of{$ident} = $args{aggregate_name};
75 }
76  
77 0 ▶ if ( $args{source} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"source"}) 0 0 0
78 $source_of{$ident} =
79 0 NetApp::Volume::Source->new( $args{source} );
80 }
81  
82 0 $clone_names_of{$ident} = $args{clone_names};
83  
84 0 ▶ if ( $args{parent_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"parent_name"}) 0 0 0
85 0 $parent_name_of{$ident} = $args{parent_name};
86 }
87  
88 0 ▶ if ( $args{snapshot_of} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"snapshot_of"}) 0 0 0
89 0 $snapshot_name_of{$ident} = $args{snapshot_name};
90 }
91  
92 0 $path_of{$ident} = "/vol/$args{name}";
93  
94 }
95  
96 0 ▶ sub get_states {
Subroutine get_states: not called CC=1 SCAR=6.9
Pod documented
97 0 return keys %{ $state_of{ident shift} };
98 }
99  
100 0 ▶ sub get_state {
Subroutine get_state: not called CC=1 SCAR=6.9
Pod documented
101
102 0 my $self = shift;
103 0 my $ident = ident $self;
104 0 my $state = shift;
105  
106 0 return $state_of{$ident}->{$state};
107  
108 }
109  
110 0 ▶ sub get_statuses { # Stati? Oh, hell no...
Subroutine get_statuses: not called CC=1 SCAR=6.9
Pod documented
111 0 return keys %{ $status_of{ident shift} };
112 }
113  
114 0 ▶ sub get_status {
Subroutine get_status: not called CC=1 SCAR=6.9
Pod documented
115  
116 0 my $self = shift;
117 0 my $ident = ident $self;
118 0 my $status = shift;
119  
120 0 return $status_of{$ident}->{$status};
121  
122 }
123
124 0 ▶ sub get_options {
Subroutine get_options: not called CC=1 SCAR=6.9
Pod documented
125 0 return keys %{ $options_of{ident shift} };
126 }
127  
128 0 ▶ sub get_option {
Subroutine get_option: not called CC=2 SCAR=17.9
Pod documented
129  
130 0 my $self = shift;
131 0 my $ident = ident $self;
132 0 my $option = shift;
133  
134 0 ▶ if ( exists $options_of{$ident}->{$option} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $options_of{$ident}{$option}) { } 0 0 0
135 0 return $options_of{$ident}->{$option};
136 } else {
137 0 return undef;
138 }
139  
140 }
141  
142 0 ▶ sub set_option {
Subroutine set_option: not called CC=3 SCAR=24.8
Pod documented
143  
144 0 my $self = shift;
145 0 my $option = shift;
146 0 ▶ my $value = $option eq 'root' ? '-f' : shift;
Branch: 1 branch
BranchTrueFalseTotal
$option eq 'root' ? : 0 0 0
147  
148 0 my $ident = ident $self;
149  
150 0 my $name = $self->get_name;
151  
152 0 my @command = ( qw(vol options), $name, $option, $value );
153  
154 0 $self->get_filer->_run_command( command => @command );
155  
156 0 ▶ if ( $option eq 'root' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option eq 'root') { } 0 0 0
157 0 $options_of{$ident}->{$option} = 1;
158 } else {
159 0 $options_of{$ident}->{$option} = $value;
160 }
161  
162 0 return 1;
163  
164 }
165  
166 0 ▶ sub get_aggregate {
Subroutine get_aggregate: not called CC=1 SCAR=6.9
Pod documented
167 0 my $self = shift;
168 0 return $self->get_filer->get_aggregate( $self->get_aggregate_name );
169 }
170  
171 0 ▶ sub get_qtree_names {
Subroutine get_qtree_names: not called CC=1 SCAR=6.9
Pod documented
172 0 my $self = shift;
173 0 return map { $_->get_name } $self->get_qtrees;
174 }
175  
176 0 ▶ sub get_qtree {
Subroutine get_qtree: not called CC=2 SCAR=17.9
Pod documented
177 0 my $self = shift;
178 0 ▶ my $name = shift || "/vol/" . $self->get_name;
Condition0%0/2
shift() || '/vol/' . $self->get_name
l!l
00
MC/DC0%0/1
shift() || '/vol/' . $self->get_name
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
179 0 return $self->get_filer->get_qtree( $name );
180 }
181  
182 0 ▶ sub get_qtrees {
Subroutine get_qtrees: not called CC=1 SCAR=6.9
Pod documented
183 0 my $self = shift;
184 0 return $self->get_filer->_get_qtree_status( volume => $self );
185 }
186  
187 0 ▶ sub get_language {
Subroutine get_language: not called CC=4 SCAR=30.0
Pod documented
188  
189 0 my $self = shift;
190  
191 0 my $name = $self->get_name;
192
193 0 $self->get_filer->_run_command(
194 command => [qw(vol language), $name],
195 );
196  
197 0 my @stdout = $self->get_filer->_get_command_stdout;
198  
199 0 my $language = "";
200  
201 0 ▶ while ( my $line = shift @stdout ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @stdout) 0 0 0
202 0 ▶ if ( $line =~ /Volume language is (\S+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /Volume language is (\S+)/) 0 0 0
203 0 $language = $1;
204 }
205 }
206  
207 0 ▶ if ( not $language ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($language) 0 0 0
208 0 croak(
209 "Unable to determine language for volume $name\n",
210 );
211 }
212  
213 0 return $language;
214  
215 }
216  
217 0 ▶ sub set_language {
Subroutine set_language: not called CC=1 SCAR=6.9
Pod documented
218  
219 0 my $self = shift;
220 0 my $language = shift;
221  
222 0 my $name = $self->get_name;
223  
224 0 return $self->get_filer->_run_command(
225 command => [qw(vol language), $name, $language],
226 );
227  
228 }
229  
230 0 ▶ sub get_size {
Subroutine get_size: not called CC=4 SCAR=30.0
Pod documented
231  
232 0 my $self = shift;
233  
234 0 my $name = $self->get_name;
235  
236 0 $self->get_filer->_run_command(
237 command => [qw(vol size), $name],
238 );
239  
240 0 my @stdout = $self->get_filer->_get_command_stdout;
241  
242 0 my $size = "";
243  
244 0 ▶ while ( defined(my $line = shift @stdout) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = shift @stdout)) 0 0 0
245 0 ▶ if ( $line =~ /has size (\S+)\./ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /has size (\S+)\./) 0 0 0
246 0 $size = $1;
247 }
248 }
249  
250 0 ▶ if ( not $size ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($size) 0 0 0
251 0 croak("Unable to determine size of volume $name\n");
252 }
253  
254 0 return $size;
255  
256 }
257  
258 0 ▶ sub set_size {
Subroutine set_size: not called CC=1 SCAR=6.9
Pod documented
259  
260 0 my $self = shift;
261 0 my $size = shift;
262  
263 0 return $self->get_filer->_run_command(
264 command => [qw(vol size), $self->get_name, $size],
265 );
266  
267 }
268  
269 0 ▶ sub get_maxfiles {
Subroutine get_maxfiles: not called CC=4 SCAR=30.0
Pod documented
270  
271 0 my $self = shift;
272  
273 0 my $name = $self->get_name;
274  
275 0 $self->get_filer->_run_command(
276 command => ['maxfiles', $name],
277 );
278  
279 0 my @stdout = $self->get_filer->_get_command_stdout;
280  
281 0 my $maxfiles = "";
282  
283 0 ▶ while ( my $line = shift @stdout ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $line = shift @stdout) 0 0 0
284 0 ▶ if ( $line =~ /is currently (\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /is currently (\d+)/) 0 0 0
285 0 $maxfiles = $1;
286 }
287 }
288  
289 0 ▶ if ( not $maxfiles ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($maxfiles) 0 0 0
290 0 croak("Unable to determine maxfiles of volume $name\n");
291 }
292  
293 0 return $maxfiles;
294  
295 }
296  
297 0 ▶ sub set_maxfiles {
Subroutine set_maxfiles: not called CC=1 SCAR=6.9
Pod documented
298  
299 0 my $self = shift;
300 0 my $maxfiles = shift;
301  
302 0 return $self->get_filer->_run_command(
303 command => ['maxfiles', $self->get_name, $maxfiles],
304 );
305  
306 }
307  
308 0 ▶ sub get_clone_names {
Subroutine get_clone_names: not called CC=1 SCAR=6.9
Pod undocumented
309  
310 0 my $self = shift;
311 0 my $ident = ident $self;
312  
313 0 return @{ $clone_names_of{$ident} };
314  
315 }
316  
317 0 ▶ sub get_clones {
Subroutine get_clones: not called CC=2 SCAR=17.9
Pod undocumented
318  
319 0 my $self = shift;
320  
321 0 my @clones = ();
322  
323 0 foreach my $clone_name ( $self->get_clone_names ) {
324 0 push @clones, $self->get_filer->get_volume( $clone_name );
325 }
326  
327 0 return @clones;
328  
329 }
330  
331 0 ▶ sub is_clone {
Subroutine is_clone: not called CC=2 SCAR=17.9
Pod documented
332 0 my $self = shift;
333 0 ▶ return ( $self->get_parent_name ? 1 : 0 );
Branch: 1 branch
BranchTrueFalseTotal
$self->get_parent_name ? : 0 0 0
334 }
335  
336 0 ▶ sub get_parent {
Subroutine get_parent: not called CC=2 SCAR=17.9
Pod documented
337 0 my $self = shift;
338 0 ▶ if ( $self->is_clone ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_clone) { } 0 0 0
339 0 return $self->get_filer->get_volume( $self->get_parent_name );
340 } else {
341 0 return;
342 }
343 }
344  
345 0 ▶ sub get_snapmirrors {
Subroutine get_snapmirrors: not called CC=1 SCAR=6.9
Pod documented
346 0 my $self = shift;
347 0 return $self->get_filer->_get_snapmirrors( volume => $self );
348 }
349  
350 0 ▶ sub get_snapshots {
Subroutine get_snapshots: not called CC=1 SCAR=6.9
Pod documented
351 0 return NetApp::Snapshot->_get_snapshots( parent => shift );
352 }
353  
354 0 ▶ sub get_snapshot {
Subroutine get_snapshot: not called CC=1 SCAR=6.9
Pod documented
355 0 my $self = shift;
356 0 my ($name) = validate_pos( @_, { type => SCALAR } );
357 0 return grep { $_->get_name eq $name } $self->get_snapshots;
358 }
359  
360 0 ▶ sub create_snapshot {
Subroutine create_snapshot: not called CC=1 SCAR=6.9
Pod documented
361 0 my $self = shift;
362 0 my ($name) = validate_pos( @_, { type => SCALAR } );
363 0 return NetApp::Snapshot->_create_snapshot(
364 parent => $self,
365 name => $name,
366 );
367 }
368  
369 0 ▶ sub delete_snapshot {
Subroutine delete_snapshot: not called CC=1 SCAR=6.9
Pod documented
370 0 my $self = shift;
371 0 my ($name) = validate_pos( @_, { type => SCALAR } );
372 0 return NetApp::Snapshot->_delete_snapshot(
373 parent => $self,
374 name => $name,
375 );
376 }
377  
378 0 ▶ sub delete_all_snapshots {
Subroutine delete_all_snapshots: not called CC=1 SCAR=6.9
Pod undocumented
379  
380 0 croak(__PACKAGE__ . "->delete_all_snapshots not yet implemented\n");
381  
382 # XXX: This one's tricky to implement. Should we parse the
383 # output, and attempt to return a list of what was delete, and
384 # what was busy? Probably too ugly.
385  
386 0 my $self = shift;
387  
388 0 return $self->get_filer->_run_command(
389 command => [ qw( snap delete -a -f -q ), $self->get_name ],
390 );
391  
392 }
393  
394 0 ▶ sub get_snapshot_deltas {
Subroutine get_snapshot_deltas: not called CC=1 SCAR=6.9
Pod documented
395 0 return NetApp::Snapshot->_get_snapshot_deltas( parent => shift );
396 }
397  
398 0 ▶ sub get_snapshot_reserved {
Subroutine get_snapshot_reserved: not called CC=1 SCAR=6.9
Pod documented
399 0 return NetApp::Snapshot->_get_snapshot_reserved( parent => shift );
400 }
401  
402 0 ▶ sub set_snapshot_reserved {
Subroutine set_snapshot_reserved: not called CC=1 SCAR=6.9
Pod documented
403 0 my $self = shift;
404 0 my ($reserved) = validate_pos( @_, { type => SCALAR } );
405 0 return NetApp::Snapshot->_set_snapshot_reserved(
406 parent => $self,
407 reserved => $reserved,
408 );
409 }
410  
411 0 ▶ sub get_snapshot_schedule {
Subroutine get_snapshot_schedule: not called CC=1 SCAR=6.9
Pod documented
412 0 return NetApp::Snapshot->_get_snapshot_schedule(
413 parent => shift,
414 @_
415 );
416 }
417  
418 0 ▶ sub set_snapshot_schedule {
Subroutine set_snapshot_schedule: not called CC=1 SCAR=6.9
Pod documented
419 0 return NetApp::Snapshot->_set_snapshot_schedule(
420 parent => shift,
421 @_
422 );
423 }
424  
425 0 ▶ sub enable_snapshot_autodelete {
Subroutine enable_snapshot_autodelete: not called CC=1 SCAR=6.9
Pod undocumented
426 0 my $self = shift;
427 0 return $self->get_filer->_run_command(
428 command => [ qw(snap autodelete), $self->get_name, qw(on) ],
429 );
430 }
431  
432 0 ▶ sub disable_snapshot_autodelete {
Subroutine disable_snapshot_autodelete: not called CC=1 SCAR=6.9
Pod documented
433 0 my $self = shift;
434 0 return $self->get_filer->_run_command(
435 command => [ qw(snap autodelete), $self->get_name, qw(off) ],
436 );
437 }
438  
439 0 ▶ sub reset_snapshot_autodelete {
Subroutine reset_snapshot_autodelete: not called CC=1 SCAR=6.9
Pod documented
440 0 my $self = shift;
441 0 return $self->get_filer->_run_command(
442 command => [ qw(snap autodelete), $self->get_name, qw(reset) ],
443 );
444 }
445  
446 0 ▶ sub set_snapshot_autodelete_option {
Subroutine set_snapshot_autodelete_option: not called CC=1 SCAR=6.9
Pod documented
447  
448 0 my $self = shift;
449  
450 0 my ($name,$value) = validate_pos(
451 @_,
452 { type => SCALAR },
453 { type => SCALAR },
454 );
455  
456 0 my @command = (
457 qw( snap autodelete ),
458 $self->get_name, $name, $value,
459 );
460  
461 0 return $self->get_filer->_run_command(
462 command => \@command,
463 );
464  
465 }
466  
467 0 ▶ sub get_snapshot_autodelete_option {
Subroutine get_snapshot_autodelete_option: not called CC=5 SCAR=34.0
Pod documented
468  
469 0 my $self = shift;
470  
471 0 my ($name) = validate_pos(
472 @_,
473 { type => SCALAR },
474 );
475  
476 0 my @command = ( qw( snap autodelete ), $self->get_name );
477  
478 0 $self->get_filer->_run_command(
479 command => \@command,
480 );
481  
482 0 my @stdout = $self->get_filer->_get_command_stdout;
483  
484 0 my $found = 0;
485 0 my $value = "";
486  
487 0 ▶ while ( defined (my $line = shift @stdout) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = shift @stdout)) 0 0 0
488 0 ▶ if ( $line =~ /^$name\s*:\s*(.*)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^$name\s*:\s*(.*)/) 0 0 0
489 0 $found = 1;
490 0 $value = $1;
491 0 ▶ $value = "" if $value eq '(not specified)';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "(not specified)" 0 0 0
492 }
493 }
494  
495 0 ▶ if ( not $found ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($found) 0 0 0
496 0 croak("Invalid autodelete option name '$name'\n");
497 }
498  
499 0 return $value;
500  
501 }
502  
503 0 ▶ sub get_temporary_exports {
Subroutine get_temporary_exports: not called CC=1 SCAR=6.9
Pod undocumented
504 0 return grep { $_->get_type eq 'temporary' } shift->get_exports;
505 }
506  
507 0 ▶ sub get_permanent_exports {
Subroutine get_permanent_exports: not called CC=1 SCAR=6.9
Pod undocumented
508 0 return grep { $_->get_type eq 'permanent' } shift->get_exports;
509 }
510  
511 0 ▶ sub get_active_exports {
Subroutine get_active_exports: not called CC=1 SCAR=6.9
Pod undocumented
512 0 return grep { $_->get_active } shift->get_exports;
513 }
514  
515 0 ▶ sub get_inactive_exports {
Subroutine get_inactive_exports: not called CC=1 SCAR=6.9
Pod undocumented
516 0 return grep { not $_->get_active } shift->get_exports;
517 }
518  
519 0 ▶ sub get_export {
Subroutine get_export: not called CC=1 SCAR=6.9
Pod undocumented
520 0 my $self = shift;
521 0 my ($path) = validate_pos( @_, { type => SCALAR } );
522 0 return grep { $_->get_path eq $path } $self->get_exports;
523 }
524  
525 0 ▶ sub get_exports {
Subroutine get_exports: not called CC=2 SCAR=17.9
Pod undocumented
526 0 my $self = shift;
527 return
528 0 ▶ grep { $_->get_path eq $self->get_path ||
Condition0%0/3
$_->get_path eq $self->get_path || $_->get_actual eq $self->get_path
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->get_path eq $self->get_path || $_->get_actual eq $self->get_path
$_->get_path eq $self->get_path $_->get_actual eq $self->get_path
Truth table0%0/3
A || B
A= $_->get_path eq $self->get_pathB= $_->get_actual eq $self->get_path
ABresult
1X1
011
000
529 $_->get_actual eq $self->get_path }
530 $self->get_filer->get_exports;
531 }
532  
533 0 ▶ sub create_export {
Subroutine create_export: not called CC=2 SCAR=17.9
Pod undocumented
534  
535 0 my $self = shift;
536  
537 0 my (%args) = validate( @_, {
538 exportas => { type => SCALAR,
539 optional => 1 },
540 type => { type => SCALAR,
541 optional => 1 },
542 nosuid => { type => SCALAR,
543 optional => 1 },
544 anon => { type => SCALAR,
545 optional => 1 },
546 sec => { type => ARRAYREF,
547 optional => 1 },
548 root => { type => ARRAYREF,
549 optional => 1 },
550 rw => { type => ARRAYREF,
551 optional => 1 },
552 ro => { type => ARRAYREF,
553 optional => 1 },
554 rw_all => { type => SCALAR,
555 optional => 1 },
556 ro_all => { type => SCALAR,
557 optional => 1 },
558 });
559  
560 0 ▶ if ( $args{exportas} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'exportas'}) { } 0 0 0
561 $args{actual} = $self->get_path,
562 $args{path} = delete $args{exportas},
563 0 } else {
564 0 $args{path} = $self->get_path;
565 }
566  
567 0 my $export = NetApp::Filer::Export->new( \%args );
568  
569 0 return $export->update;
570  
571 }
572  
573 0 ▶ sub destroy_export {
Subroutine destroy_export: not called CC=1 SCAR=6.9
Pod undocumented
574  
575 0 my $self = shift;
576  
577 # XXX: Hmm....
578  
579 }
580  
581 0 ▶ sub offline {
Subroutine offline: not called CC=2 SCAR=17.9
Pod documented
582  
583 0 my $self = shift;
584 0 my $ident = ident $self;
585  
586 0 my (%args) = validate( @_, {
587 cifsdelaytime => { type => SCALAR,
588 optional => 1 },
589 });
590  
591 0 my @command = ( qw(vol offline), $self->get_name );
592  
593 0 ▶ if ( $args{cifsdelaytime} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"cifsdelaytime"}) 0 0 0
594 0 push @command, '-t', $args{cifsdelaytime};
595 }
596  
597 $self->get_filer->_run_command(
598 0 command => \@command,
599 );
600  
601 0 delete $state_of{$ident}->{online};
602 0 delete $state_of{$ident}->{restricted};
603 0 $state_of{$ident}->{offline} = 1;
604
605 0 return 1;
606  
607 }
608  
609 0 ▶ sub online {
Subroutine online: not called CC=2 SCAR=17.9
Pod documented
610  
611 0 my $self = shift;
612 0 my $ident = ident $self;
613  
614 0 my (%args) = validate( @_, {
615 force => { type => SCALAR,
616 optional => 1 },
617 });
618  
619 0 my @command = ( qw( vol online ), $self->get_name );
620  
621 0 ▶ if ( $args{force} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"force"}) 0 0 0
622 0 push @command, '-f';
623 }
624
625 $self->get_filer->_run_command(
626 0 command => \@command,
627 );
628  
629 0 delete $state_of{$ident}->{offline};
630 0 delete $state_of{$ident}->{restricted};
631 0 $state_of{$ident}->{online} = 1;
632
633 0 return 1;
634  
635 }
636  
637 0 ▶ sub rename {
Subroutine rename: not called CC=1 SCAR=6.9
Pod documented
638  
639 0 my $self = shift;
640 0 my $ident = ident shift;
641  
642 0 my (%args) = validate( @_, {
643 newname => { type => SCALAR },
644 });
645  
646 0 my $oldname = $self->get_name;
647  
648 $self->get_filer->_run_command(
649 0 command =>[qw(vol rename), $oldname, $args{newname}],
650 );
651  
652 0 $name_of{$ident} = $args{newname};
653  
654 0 return 1;
655  
656 }
657  
658 0 ▶ sub restrict {
Subroutine restrict: not called CC=2 SCAR=17.9
Pod documented
659
660 0 my $self = shift;
661 0 my $ident = ident shift;
662  
663 0 my (%args) = validate( @_, {
664 cifsdelaytime => { type => SCALAR,
665 optional => 1 },
666 });
667  
668 0 my @command = ( qw(vol restrict), $self->get_name );
669  
670 0 ▶ if ( $args{cifsdelaytime} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"cifsdelaytime"}) 0 0 0
671 0 push @command, '-t', $args{cifsdelaytime};
672 }
673  
674 $self->get_filer->_run_command(
675 0 command => \@command,
676 );
677  
678 0 delete $state_of{$ident}->{offline};
679 0 delete $state_of{$ident}->{online};
680 0 $state_of{$ident}->{restricted} = 1;
681  
682 0 return 1;
683  
684 }
685  
686 }
687  
688 1 ▶sub _parse_vol_status_headers {
Subroutine _parse_vol_status_headers: called CC=6 SCAR=17.9
689  
690 6 my $class = shift;
691 6 my $header = shift;
692  
693 6 my $indices = {};
694 6 my $index = 0;
695  
696 6 ▶ my ($volume) = ( $header =~ /(^\s+Volume\s+)/ ) or
Branch: 1 branch
BranchTrueFalseTotal
my($volume) = $header =~ /(^\s+Volume\s+)/ or croak("Unable to match 'Volume' column header\n") 5 1 6
697 croak(
698 "Unable to match 'Volume' column header\n"
699 );
700  
701 5 $indices->{volume} = [ 0, length($volume) ];
702 5 $index += length($volume);
703  
704 5 ▶ my ($state) = ( $header =~ /(State\s+)/ ) or
Branch: 1 branch
BranchTrueFalseTotal
my($state) = $header =~ /(State\s+)/ or croak("Unable to match 'State' column header\n") 4 1 5
705 croak(
706 "Unable to match 'State' column header\n"
707 );
708  
709 4 $indices->{state} = [ $index, length($state) ];
710 4 $index += length($state);
711  
712 4 ▶ my ($status) = ( $header =~ /(Status\s+)/ ) or
Branch: 1 branch
BranchTrueFalseTotal
my($status) = $header =~ /(Status\s+)/ or croak("Unable to match 'Status' column header\n") 3 1 4
713 croak(
714 "Unable to match 'Status' column header\n"
715 );
716
717 3 $indices->{status} = [ $index, length($status) ];
718 3 $index += length($status);
719  
720 3 ▶ my ($options) = ( $header =~ /(Options\s*)/ ) or
Branch: 1 branch
BranchTrueFalseTotal
my($options) = $header =~ /(Options\s*)/ or croak("Unable to match 'Options' column header\n") 2 1 3
721 croak(
722 "Unable to match 'Options' column header\n"
723 );
724
725 2 $indices->{options} = [ $index ];
726  
727 2 ▶ if ( $header =~ /Source/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($header =~ /Source/) 1 1 2
728 1 $indices->{options}->[1] = length($options);
729 1 $index += length($options);
730 1 $indices->{source} = [ $index ];
731 }
732  
733 2 $indices->{length} = $index + 1;
734  
735 2 return $indices;
736  
737 }
738  
739 4 ▶sub _parse_vol_status_volume {
Subroutine _parse_vol_status_volume: called CC=15 SCAR=29.5
740  
741 4 my $class = shift;
742
743 4 my %args = validate( @_, {
744 indices => { type => HASHREF },
745 line => { type => SCALAR },
746 volume => { type => HASHREF,
747 default => {},
748 optional => 1 },
749 });
750
751 4 my $indices = $args{indices};
752 4 my $volume = $args{volume};
753 4 my $line = $args{line};
754  
755 4 ▶ if ( $line =~ /Clone, backed by volume '(.*)', snapshot '(.*)'/ ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /Clone, backed by volume '(.*)', snapshot '(.*)'/) { } 0 4 4
elsif ($line =~ /Volume has clones: (.*)/) { } 0 4 4
elsif ($line =~ /Containing aggregate: (\S+)/) { } 0 4 4
756  
757 0 $volume->{parent_name} = $1;
758 0 $volume->{snapshot_name} = $2;
759 0 return $volume;
760  
761 } elsif ( $line =~ /Volume has clones: (.*)/ ) {
762  
763 0 my $clones = $1;
764 0 $volume->{clone_names} = [ split( /[,\s]+/, $clones ) ];
765 0 return $volume;
766  
767 } elsif ( $line =~ /Containing aggregate: (\S+)/ ) {
768  
769 0 my $aggrname = $1;
770 0 $aggrname =~ s/'//g;
771 0 ▶ if ( $aggrname ne '<N/A>' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($aggrname ne "<N/A>") 0 0 0
772 0 $volume->{aggregate_name} = $aggrname;
773 }
774 0 return $volume;
775  
776 }
777  
778 4 ▶ if ( length($line) < $indices->{length} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $line < $indices->{"length"}) 0 4 4
779 0 $line .= " " x ( $indices->{length} - length($line) );
780 }
781  
782 4 foreach my $column ( qw( volume state status options source ) ) {
783  
784 20 my $value = "";
785  
786 20 ▶ next unless $indices->{$column};
Branch: 1 branch
BranchTrueFalseTotal
unless $indices->{$column} 3 17 20
787  
788 17 ▶ if ( defined $indices->{$column}->[1] ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $indices->{$column}[1]) { } 13 4 17
789 $value = substr( $line,
790 $indices->{$column}->[0],
791 13 $indices->{$column}->[1] );
792 } else {
793 $value = substr( $line,
794 4 $indices->{$column}->[0] );
795 }
796  
797 17 $value =~ s/$RE{ws}{crop}//g;
798  
799 17 ▶ if ( $column eq 'volume' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($column eq 'volume') { } 4 13 17
elsif ($column eq 'source') { } 1 12 13
800  
801 4 ▶ if ( $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value) 2 2 4
802  
803 2 $volume->{name} = $value;
804  
805 2 my ($name) = split( /\s+/, $line );
806  
807 2 ▶ if ( length($name) > length($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $name > length $value) 1 1 2
808 1 $volume->{name} = $name;
809 1 $line =~ s/^$name/$value/;
810 }
811  
812 }
813  
814 } elsif ( $column eq 'source' ) {
815  
816 1 my ($hostname,$source) = split( /:/, $value );
817  
818 $volume->{source} = {
819 1 hostname => $hostname,
820 volume => $source,
821 };
822  
823 1 $indices->{options}->[1] = undef;
824  
825 1 delete $indices->{source};
826  
827 } else {
828  
829 12 foreach my $entry ( split( /[,\s]+/, $value ) ) {
830  
831 15 my ($key,$value);
832  
833 15 ▶ if ( $entry =~ /=/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry =~ /=/) { } 8 7 15
834 8 ($key,$value) = split( /=/, $entry, 2 );
835 } else {
836 7 ($key,$value) = ($entry,1);
837 }
838  
839 15 $volume->{$column}->{$key} = $value;
840  
841 }
842  
843 }
844  
845 }
846  
847 4 return $volume;
848  
849 }
850  
851 1 1;
« NetApp/Aggregate.pm ↑ Summary NetApp/Qtree.pm »