NetApp/Snapmirror.pm

filter: Statementstmt 75.3% 61 / 81 Branchbran 62.5% 5 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 1 totaltotal 76.4% 81 / 106 CC 6 SCAR 10.6
CC
6
Cov
75%
BUILD
6.0
_parse_snapmirror_status
5.0
BEGIN
1.0
CRAP 2.9
« NetApp/Snapshot/Schedule.pm ↑ Summary NetApp/Aggregate/Plex.pm »
1  
2 package NetApp::Snapmirror;
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::Snapmirror::Source;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use NetApp::Snapmirror::Destination;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 {
20  
21 1 my %filer_of :ATTR( get => 'filer' );
22  
23 1 my %source_of :ATTR( get => 'source' );
24 1 my %destination_of :ATTR( get => 'destination' );
25  
26 1 my %status_of :ATTR( get => 'status' );
27 1 my %progress_of :ATTR( get => 'progress' );
28 1 my %state_of :ATTR( get => 'state' );
29 1 my %lag_of :ATTR( get => 'lag' );
30  
31 1 my %mirror_timestamp_of :ATTR( get => 'mirror_timestamp' );
32 1 my %base_snapshot_of :ATTR( get => 'base_snapshot' );
33 1 my %current_transfer_type_of
34 :ATTR( get => 'current_transfer_type' );
35 1 my %current_transfer_error_of
36 :ATTR( get => 'current_transfer_error' );
37 1 my %contents_of :ATTR( get => 'contents' );
38 1 my %last_transfer_type_of
39 :ATTR( get => 'last_transfer_type' );
40 1 my %last_transfer_size_of
41 :ATTR( get => 'last_transfer_size' );
42 1 my %last_transfer_duration_of
43 :ATTR( get => 'last_transfer_duration' );
44 1 my %last_transfer_from_of
45 :ATTR( get => 'last_transfer_from' );
46  
47 0 ▶ sub BUILD {
Subroutine BUILD: not called CC=2 SCAR=17.9
Pod undocumented
48  
49 0 my ($self,$ident,$args_ref) = @_;
50  
51 0 my @args = %$args_ref;
52  
53 0 my (%args) = validate( @args, {
54 filer => { isa => 'NetApp::Filer' },
55 source => { type => HASHREF,
56 optional => 1 },
57 destination => { type => HASHREF },
58 status => { type => SCALAR },
59 progress => { type => SCALAR },
60 state => { type => SCALAR },
61 lag => { type => SCALAR },
62 mirror_timestamp => { type => SCALAR },
63 base_snapshot => { type => SCALAR },
64 current_transfer_type => { type => SCALAR },
65 current_transfer_error => { type => SCALAR },
66 contents => { type => SCALAR },
67 last_transfer_type => { type => SCALAR },
68 last_transfer_size => { type => SCALAR },
69 last_transfer_duration => { type => SCALAR },
70 last_transfer_from => { type => SCALAR },
71 });
72  
73 0 $filer_of{$ident} = $args{filer};
74  
75 0 ▶ if ( $args{source} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{"source"}) 0 0 0
76 $source_of{$ident} =
77 0 NetApp::Snapmirror::Source->new( $args{source} );
78 }
79  
80 $destination_of{$ident} =
81 0 NetApp::Snapmirror::Destination->new( $args{destination} );
82  
83 0 $status_of{$ident} = $args{status};
84 0 $progress_of{$ident} = $args{progress};
85 0 $state_of{$ident} = $args{state};
86 0 $lag_of{$ident} = $args{lag};
87 0 $mirror_timestamp_of{$ident} = $args{mirror_timestamp};
88 0 $base_snapshot_of{$ident} = $args{base_snapshot};
89 0 $current_transfer_type_of{$ident} = $args{current_transfer_type};
90 0 $current_transfer_error_of{$ident} = $args{current_transfer_error};
91 0 $contents_of{$ident} = $args{contents};
92 0 $last_transfer_type_of{$ident} = $args{last_transfer_type};
93 0 $last_transfer_size_of{$ident} = $args{last_transfer_size};
94 0 $last_transfer_duration_of{$ident} = $args{last_transfer_duration};
95 0 $last_transfer_from_of{$ident} = $args{last_transfer_from};
96  
97 }
98  
99 }
100  
101 1 ▶sub _parse_snapmirror_status {
Subroutine _parse_snapmirror_status: called CC=5 SCAR=16.1
102  
103 15 my $class = shift;
104  
105 15 my (%args) = validate( @_, {
106 snapmirror => { type => HASHREF },
107 line => { type => SCALAR },
108 });
109  
110 15 my $snapmirror = $args{snapmirror};
111 15 my $line = $args{line};
112  
113 15 my ($key,$value) = split( /:\s+/, $line, 2 );
114  
115 # 'Last Transfer Type' => 'last_transfer_type'
116 15 $key =~ s/\s/_/g;
117 15 $key = lc($key);
118  
119 15 ▶ if ( $value eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value eq "-") 5 10 15
120 5 $value = '';
121 }
122  
123 15 ▶ if ( $key eq 'source' || $key eq 'destination' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq 'source' or $key eq 'destination') { } 2 13 15
Condition100%3/3
$key eq "source" or $key eq "destination"
l!l&&r!l&&!r
1113
MC/DC100%2/2
$key eq "source" or $key eq "destination"
$key eq "source" $key eq "destination"
Truth table100%3/3
A or B
A= $key eq "source"B= $key eq "destination"
ABresult
1X1
011
000
124 2 ▶ if ( my ($hostname,$volume) = split( /:/, $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = split(/:/, $value, 3)) 2 0 2
125 2 $snapmirror->{$key} = {
126 hostname => $hostname,
127 volume => $volume,
128 };
129 }
130 } else {
131 13 $snapmirror->{$key} = $value;
132 }
133  
134 15 return $snapmirror;
135  
136 }
137  
138 1 1;
« NetApp/Snapshot/Schedule.pm ↑ Summary NetApp/Aggregate/Plex.pm »