| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 120 | 5 | $value = ''; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 15 | ▶ | if ( $key eq 'source' || $key eq 'destination' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$key eq "source" or $key eq "destination"
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"
| |||||||||||||||||||||||||||||
| 124 | 2 | ▶ | if ( my ($hostname,$volume) = split( /:/, $value ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||