NetApp/Qtree.pm

filter: Statementstmt 49.4% 48 / 97 Branchbran 22.2% 4 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.1% 8 / 19 Podpod 18.1% 2 / 11 totaltotal 42.7% 62 / 145 CC 11 SCAR 18.1
CC
11
Cov
45%
get_exports
20.0
set_oplocks
12.0
BUILD
6.0
CRAP 6.1
« NetApp/Volume.pm ↑ Summary NetApp/Snapshot/Delta.pm »
1  
2 package NetApp::Qtree;
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 {
17  
18 1 my %filer_of :ATTR( get => 'filer' );
19  
20 1 my %volume_name_of :ATTR( get => 'volume_name' );
21  
22 1 my %name_of :ATTR( get => 'name' );
23 1 my %security_of :ATTR( get => 'security' );
24 1 my %oplocks_of :ATTR( get => 'oplocks' );
25 1 my %status_of :ATTR( get => 'status' );
26 1 my %id_of :ATTR( get => 'id' );
27 1 my %vfiler_of :ATTR( get => 'vfiler' );
28  
29 0 ▶ sub BUILD {
Subroutine BUILD: not called CC=2 SCAR=17.9
Pod undocumented
30  
31 0 my ($self,$ident,$args_ref) = @_;
32  
33 0 my @args = %$args_ref;
34  
35 0 my (%args) = validate( @args, {
36 filer => { isa => 'NetApp::Filer' },
37 volume_name => { type => SCALAR },
38 name => { type => SCALAR },
39 security => { type => SCALAR },
40 oplocks => { type => SCALAR },
41 status => { type => SCALAR },
42 id => { type => SCALAR },
43 vfiler => { type => SCALAR,
44 optional => 1 },
45 });
46  
47 0 $filer_of{$ident} = $args{filer};
48 0 $volume_name_of{$ident} = $args{volume_name};
49  
50 0 $name_of{$ident} = $args{name};
51 0 $security_of{$ident} = $args{security};
52 0 $oplocks_of{$ident} = $args{oplocks};
53 0 $status_of{$ident} = $args{status};
54 0 $id_of{$ident} = $args{id};
55  
56 0 ▶ if ( $args{vfiler} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"vfiler"}) 0 0 0
57 0 $vfiler_of{$ident} = $args{vfiler};
58 }
59  
60 }
61  
62 0 ▶ sub get_volume {
Subroutine get_volume: not called CC=1 SCAR=6.9
Pod undocumented
63 0 my $self = shift;
64 0 return $self->get_filer->get_volume( $self->get_volume_name );
65 }
66  
67 0 ▶ sub get_aggregate {
Subroutine get_aggregate: not called CC=1 SCAR=6.9
Pod undocumented
68 0 return shift->get_volume->get_aggregate;
69 }
70  
71 0 ▶ sub set_security {
Subroutine set_security: not called CC=2 SCAR=17.9
Pod documented
72  
73 0 my $self = shift;
74 0 my $ident = ident $self;
75 0 my $security = shift;
76  
77 0 ▶ if ( $security !~ /^(unix|ntfs|mixed)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($security =~ /^(unix|ntfs|mixed)$/) 0 0 0
78 0 croak("Invalid qtree security value: $security\n");
79 }
80  
81 0 my $name = $self->get_name;
82  
83 0 $self->get_filer->_run_command(
84 command => [qw( qtree security ), $name, $security ],
85 );
86  
87 0 $security_of{$ident} = $security;
88  
89 }
90  
91 0 ▶ sub set_oplocks {
Subroutine set_oplocks: not called CC=3 SCAR=24.8
Pod documented
92  
93 0 my $self = shift;
94 0 my $ident = ident $self;
95  
96 0 my $state = shift;
97  
98 0 ▶ my $enable = $state ? 'enable' : 'disable';
Branch: 1 branch
BranchTrueFalseTotal
$state ? : 0 0 0
99  
100 0 my $name = $self->get_name;
101  
102 0 $self->get_filer->_run_command(
103 command => [qw( qtree oplocks ), $name, $enable ],
104 );
105  
106 0 ▶ $oplocks_of{$ident} = $enable eq 'enable' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$enable eq 'enable' ? : 0 0 0
107  
108 }
109  
110 0 ▶ sub get_temporary_exports {
Subroutine get_temporary_exports: not called CC=1 SCAR=6.9
Pod undocumented
111 0 return grep { $_->get_type eq 'temporary' } shift->get_exports;
112 }
113  
114 0 ▶ sub get_permanent_exports {
Subroutine get_permanent_exports: not called CC=1 SCAR=6.9
Pod undocumented
115 0 return grep { $_->get_type eq 'permanent' } shift->get_exports;
116 }
117  
118 0 ▶ sub get_active_exports {
Subroutine get_active_exports: not called CC=1 SCAR=6.9
Pod undocumented
119 0 return grep { $_->get_active } shift->get_exports;
120 }
121  
122 0 ▶ sub get_inactive_exports {
Subroutine get_inactive_exports: not called CC=1 SCAR=6.9
Pod undocumented
123 0 return grep { not $_->get_active } shift->get_exports;
124 }
125  
126 0 ▶ sub get_export {
Subroutine get_export: not called CC=1 SCAR=6.9
Pod undocumented
127 0 my $self = shift;
128 0 my ($path) = validate_pos( @_, { type => SCALAR } );
129 0 return grep { $_->get_path eq $path } $self->get_exports;
130 }
131  
132 0 ▶ sub get_exports {
Subroutine get_exports: not called CC=4 SCAR=30.0
Pod undocumented
133  
134 0 my $self = shift;
135  
136 0 my @exports = ();
137  
138 0 foreach my $export ( $self->get_filer->get_exports ) {
139  
140 0 ▶ if ( $export->get_path eq $self->get_name ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($export->get_path eq $self->get_name) { } 0 0 0
elsif ($export->get_actual eq $self->get_name) { } 0 0 0
141 0 push @exports, $export;
142 } elsif ( $export->get_actual eq $self->get_name ) {
143 0 push @exports, $export;
144 }
145  
146 }
147  
148 0 return @exports;
149  
150 }
151  
152 }
153  
154 1 ▶sub _parse_qtree_status_qtree {
Subroutine _parse_qtree_status_qtree: called CC=4 SCAR=13.9
155  
156 2 my $class = shift;
157 2 my $line = shift;
158  
159 2 my $qtree = {};
160  
161 2 my @data = split( /\s+/, $line );
162  
163 2 $qtree->{volume_name} = shift @data;
164  
165 2 $qtree->{name} = "/vol/$qtree->{volume_name}";
166  
167 2 ▶ if ( $data[0] !~ /^(unix|ntfs|mixed)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($data[0] =~ /^(unix|ntfs|mixed)$/) 1 1 2
168 1 $qtree->{name} .= "/" . shift @data;
169 }
170  
171 2 $qtree->{security} = $data[0];
172 2 ▶ $qtree->{oplocks} = $data[1] eq 'enabled' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$data[1] eq 'enabled' ? : 2 0 2
173 2 $qtree->{status} = $data[2];
174 2 $qtree->{id} = $data[3];
175  
176 2 ▶ if ( $data[4] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data[4]) 2 0 2
177 2 $qtree->{vfiler} = $data[4];
178 }
179  
180 2 return $qtree;
181  
182 }
183  
184 1 1;
« NetApp/Volume.pm ↑ Summary NetApp/Snapshot/Delta.pm »