| 1 | |||||||||||||||||||||||||||||
| 2 | package NetApp::Snapshot; | ||||||||||||||||||||||||||||
| 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::Snapshot::Delta; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use NetApp::Snapshot::Schedule; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | { | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 1 | my %parent_of :ATTR( get => 'parent' ); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 1 | my %name_of :ATTR( get => 'name' ); | |||||||||||||||||||||||||||
| 24 | 1 | my %date_of :ATTR( get => 'date' ); | |||||||||||||||||||||||||||
| 25 | 1 | my %used_of :ATTR( get => 'used' ); | |||||||||||||||||||||||||||
| 26 | 1 | my %total_of :ATTR( get => 'total' ); | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | sub BUILD { | ||||||||||||||||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 0 | my ($self,$ident,$args_ref) = @_; | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 0 | my @args = %$args_ref; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | my (%args) = validate( @args, { | |||||||||||||||||||||||||||
| 35 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 36 | name => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 37 | date => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 38 | used => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 39 | total => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 40 | }); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | $parent_of{$ident} = $args{parent}; | |||||||||||||||||||||||||||
| 43 | 0 | $name_of{$ident} = $args{name}; | |||||||||||||||||||||||||||
| 44 | 0 | $date_of{$ident} = $args{date}; | |||||||||||||||||||||||||||
| 45 | 0 | $used_of{$ident} = $args{used}; | |||||||||||||||||||||||||||
| 46 | 0 | $total_of{$ident} = $args{total}; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub get_filer { | ||||||||||||||||||||||||||
|
Subroutine
get_filer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 51 | 0 | return shift->get_parent->get_filer; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | ▶ | sub get_snapshot_deltas { | ||||||||||||||||||||||||||
|
Subroutine
get_snapshot_deltas: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 0 | return $self->_get_snapshot_deltas( | |||||||||||||||||||||||||||
| 59 | parent => $self->get_parent, | ||||||||||||||||||||||||||||
| 60 | from => $self, | ||||||||||||||||||||||||||||
| 61 | ); | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | ▶ | sub get_reclaimable { | ||||||||||||||||||||||||||
|
Subroutine
get_reclaimable: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( $self->get_parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | croak("Aggregate snapshots do not support 'snap reclaimable'\n"); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | $self->get_filer->_run_command( | ||||||||||||||||||||||||||||
| 74 | 0 | command => [ qw( snap reclaimable ), | |||||||||||||||||||||||||||
| 75 | $self->get_parent->get_name, | ||||||||||||||||||||||||||||
| 76 | $self->get_name ], | ||||||||||||||||||||||||||||
| 77 | nonfatal => 1, | ||||||||||||||||||||||||||||
| 78 | ); | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 0 | my @stdout = $self->get_filer->_get_command_stdout; | |||||||||||||||||||||||||||
| 81 | 0 | my @stderr = $self->get_filer->_get_command_stderr; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | while ( defined (my $line = shift @stdout) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 84 | 0 | ▶ | if ( $line =~ /Approximately (\d+)/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 0 | return $1; | |||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | carp( | ||||||||||||||||||||||||||||
| 90 | 0 | "Unable to determine reclaimable space for ", | |||||||||||||||||||||||||||
| 91 | $self->get_parent->get_name, ":", | ||||||||||||||||||||||||||||
| 92 | $self->get_name, "\n", | ||||||||||||||||||||||||||||
| 93 | @stderr, | ||||||||||||||||||||||||||||
| 94 | ); | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 0 | return undef; | |||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | ▶ | sub restore { | ||||||||||||||||||||||||||
|
Subroutine
restore: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 105 | type => { type => SCALAR, | ||||||||||||||||||||||||||||
| 106 | regexp => qr{^(vol|file)$}, | ||||||||||||||||||||||||||||
| 107 | default => 'vol', | ||||||||||||||||||||||||||||
| 108 | optional => 1 }, | ||||||||||||||||||||||||||||
| 109 | from_path => { type => SCALAR, | ||||||||||||||||||||||||||||
| 110 | optional => 1 }, | ||||||||||||||||||||||||||||
| 111 | to_path => { type => SCALAR, | ||||||||||||||||||||||||||||
| 112 | optional => 1 }, | ||||||||||||||||||||||||||||
| 113 | }); | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( $args{type} eq 'file' && ! $args{from_path} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"type"} eq "file" and not $args{"from_path"}
MC/DC0%0/2
$args{"type"} eq "file" and not $args{"from_path"}
$args{"type"} eq "file"
not $args{"from_path"}
Truth table0%0/3
A and not(B)
A= $args{"type"} eq "file"B= not $args{"from_path"}
| |||||||||||||||||||||||||||||
| 116 | 0 | croak( | |||||||||||||||||||||||||||
| 117 | "Missing required argment 'from_path'\n", | ||||||||||||||||||||||||||||
| 118 | "File restores must specify the from_path\n", | ||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if ( $args{type} eq 'vol' && $args{to_path} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"type"} eq "vol" and $args{"to_path"}
MC/DC0%0/2
$args{"type"} eq "vol" and $args{"to_path"}
$args{"type"} eq "vol"
$args{"to_path"}
Truth table0%0/3
A and B
A= $args{"type"} eq "vol"B= $args{"to_path"}
| |||||||||||||||||||||||||||||
| 123 | 0 | croak( | |||||||||||||||||||||||||||
| 124 | "Invalid argument 'to_path'\n", | ||||||||||||||||||||||||||||
| 125 | "Volume restores can not specify to_path\n", | ||||||||||||||||||||||||||||
| 126 | ); | ||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my @command = qw( snap restore ); | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ( $self->get_parent->isa("NetApp::Aggregate" ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | ▶ | if ( $args{to_path} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 0 | push @command, '-r', $args{to_path}; | |||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | push @command, ( | ||||||||||||||||||||||||||||
| 140 | qw( -f -s ), $self->get_name, | ||||||||||||||||||||||||||||
| 141 | qw( -t ), $args{type}, | ||||||||||||||||||||||||||||
| 142 | 0 | ); | |||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if ( $args{type} eq 'vol' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 145 | 0 | push @command, $self->get_parent->get_name; | |||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||
| 147 | 0 | push @command, $args{from_path}; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | 0 | return $self->get_filer->_run_command( | |||||||||||||||||||||||||||
| 151 | command => \@command, | ||||||||||||||||||||||||||||
| 152 | ); | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub rename { | ||||||||||||||||||||||||||
|
Subroutine
rename: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 159 | 0 | my $ident = ident $self; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | my ($newname) = validate_pos( | |||||||||||||||||||||||||||
| 162 | @_, | ||||||||||||||||||||||||||||
| 163 | { type => SCALAR }, | ||||||||||||||||||||||||||||
| 164 | ); | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | my @command = qw( snap rename ); | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ( $self->get_parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | push @command, $self->get_name, $newname; | |||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | 0 | $self->_run_command( | |||||||||||||||||||||||||||
| 175 | command => \@command, | ||||||||||||||||||||||||||||
| 176 | ); | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | $name_of{$ident} = $newname; | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | return 1; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | # NOTE: These are class methods, since you can request snapshots, | ||||||||||||||||||||||||||||
| 187 | # deltas, etc from an aggregate, volume, or a specific snapshot. | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | 1 | ▶ | sub _get_snapshots { | ||||||||||||||||||||||||||
|
Subroutine
_get_snapshots: not called CC=9 SCAR=44.3
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 194 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 195 | }); | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | my @command = qw( snap list ); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 0 | push @command, $parent->get_name; | |||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 208 | command => \@command, | ||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | my @stdout = $parent->get_filer->_get_command_stdout; | |||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | 0 | my @snapshots = (); | |||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | while ( defined (my $line = shift @stdout) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | next if $line =~ /^(Volume|Aggregate)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | next if $line =~ /^working/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | next if $line =~ /^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 0 | ▶ | last if $line =~ /No snapshots exist/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | next if $line =~ m:^\s*%/used:; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 0 | ▶ | next if $line =~ /^-+/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | my $snapshot = $class->_parse_snap_list( $line ); | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | push @snapshots, NetApp::Snapshot->new({ | |||||||||||||||||||||||||||
| 229 | parent => $parent, | ||||||||||||||||||||||||||||
| 230 | %$snapshot, | ||||||||||||||||||||||||||||
| 231 | }); | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | return @snapshots; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub _create_snapshot { | ||||||||||||||||||||||||||
|
Subroutine
_create_snapshot: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 244 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 245 | name => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 246 | }); | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | 0 | my @command = qw( snap create ); | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | push @command, $args{name}; | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | return $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 259 | command => \@command, | ||||||||||||||||||||||||||||
| 260 | ); | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub _delete_snapshot { | ||||||||||||||||||||||||||
|
Subroutine
_delete_snapshot: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 269 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 270 | name => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 271 | }); | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | my @command = qw( snap delete ); | |||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 278 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | 0 | push @command, $args{name}; | |||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 0 | return $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 284 | command => \@command, | ||||||||||||||||||||||||||||
| 285 | ); | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | sub _set_snapshot_schedule { | ||||||||||||||||||||||||||
|
Subroutine
_set_snapshot_schedule: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 294 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 295 | weekly => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 296 | daily => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 297 | hourly => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 298 | hourlist => { type => ARRAYREF, | ||||||||||||||||||||||||||||
| 299 | optional => 1 }, | ||||||||||||||||||||||||||||
| 300 | }); | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | 0 | my @command = qw( snap sched ); | |||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 0 | push @command, $parent->get_name, $args{weekly}, $args{daily}; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | my $hourly = $args{hourly}; | |||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | ▶ | if ( $args{hourlist} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 315 | 0 | $hourly .= '@' . join( ',', @{ $args{hourlist} } ); | |||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 0 | push @command, $args{hourly}; | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 0 | return $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 321 | command => \@command, | ||||||||||||||||||||||||||||
| 322 | ); | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | ▶ | sub _get_snapshot_schedule { | ||||||||||||||||||||||||||
|
Subroutine
_get_snapshot_schedule: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 331 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 332 | }); | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | my @command = qw( snap sched ); | |||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | push @command, $parent->get_name; | |||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 0 | $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 345 | command => \@command, | ||||||||||||||||||||||||||||
| 346 | ); | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 0 | my @stdout = $parent->get_filer->_get_command_stdout; | |||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 0 | my $schedule = | |||||||||||||||||||||||||||
| 351 | NetApp::Snapshot::Schedule->_parse_snap_sched( shift @stdout ); | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 0 | return NetApp::Snapshot::Schedule->new({ | |||||||||||||||||||||||||||
| 354 | parent => $parent, | ||||||||||||||||||||||||||||
| 355 | %$schedule, | ||||||||||||||||||||||||||||
| 356 | }); | ||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||
| 360 | 0 | ▶ | sub _set_snapshot_reserved { | ||||||||||||||||||||||||||
|
Subroutine
_set_snapshot_reserved: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||
| 364 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 365 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 366 | reserved => { type => SCALAR }, | ||||||||||||||||||||||||||||
| 367 | }); | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 370 | 0 | my $reserved = $args{reserved}; | |||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 0 | my @command = qw( snap reserve ); | |||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 375 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | 0 | push @command, $parent->get_name, $reserved; | |||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 0 | return $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 381 | command => \@command, | ||||||||||||||||||||||||||||
| 382 | ); | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | 0 | ▶ | sub _get_snapshot_reserved { | ||||||||||||||||||||||||||
|
Subroutine
_get_snapshot_reserved: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 391 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 392 | }); | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 395 | 0 | my $parent_class = ref $parent; | |||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 0 | my @command = qw( snap reserve ); | |||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 400 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 401 | } | ||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | push @command, $parent->get_name; | |||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | $parent->get_filer->_run_command( | |||||||||||||||||||||||||||
| 406 | command => \@command, | ||||||||||||||||||||||||||||
| 407 | ); | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | 0 | my @stdout = $parent->get_filer->_get_command_stdout; | |||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 0 | my $line = shift @stdout; | |||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | ▶ | if ( $line =~ /reserve is (\d+)%/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 414 | 0 | return $1; | |||||||||||||||||||||||||||
| 415 | } else { | ||||||||||||||||||||||||||||
| 416 | 0 | croak( | |||||||||||||||||||||||||||
| 417 | "Unable to determine snapshot reserve for $parent_class", | ||||||||||||||||||||||||||||
| 418 | $parent->get_name, "\n", | ||||||||||||||||||||||||||||
| 419 | ); | ||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | } | ||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | 0 | ▶ | sub _get_snapshot_deltas { | ||||||||||||||||||||||||||
|
Subroutine
_get_snapshot_deltas: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | 0 | my $class = shift; | |||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 0 | my (%args) = validate( @_, { | |||||||||||||||||||||||||||
| 429 | parent => { type => OBJECT }, | ||||||||||||||||||||||||||||
| 430 | from => { isa => 'NetApp::Snapshot', | ||||||||||||||||||||||||||||
| 431 | optional => 1 }, | ||||||||||||||||||||||||||||
| 432 | to => { isa => 'NetApp::Snapshot', | ||||||||||||||||||||||||||||
| 433 | depends => [qw( from )], | ||||||||||||||||||||||||||||
| 434 | optional => 1 }, | ||||||||||||||||||||||||||||
| 435 | }); | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 0 | my $parent = $args{parent}; | |||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||
| 439 | 0 | my @command = qw( snap delta ); | |||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | 0 | ▶ | if ( $parent->isa("NetApp::Aggregate") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | 0 | push @command, '-A'; | |||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | 0 | push @command, $parent->get_name; | |||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if ( $args{from} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | 0 | push @command, $args{from}->get_name; | |||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ( $args{to} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 452 | 0 | push @command, $args{to}->get_name; | |||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | $parent->get_filer->_run_command( | ||||||||||||||||||||||||||||
| 456 | 0 | command => \@command, | |||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 0 | my @stdout = $parent->get_filer->_get_command_stdout; | |||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | 0 | my @deltas = (); | |||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | 0 | my $summary = 0; | |||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | while ( defined( my $line = shift @stdout) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||
| 467 | 0 | ▶ | next if $line =~ /^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 468 | 0 | ▶ | next if $line =~ /^(Volume|Aggregate|working|From)/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 469 | 0 | ▶ | next if $line =~ /^[-\s]+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | 0 | ▶ | last if $line =~ /No snapshots exist/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if ( $line =~ /^Summary/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 474 | 0 | $summary = 1; | |||||||||||||||||||||||||||
| 475 | 0 | next; | |||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | 0 | my $delta = NetApp::Snapshot::Delta->_parse_snap_delta( $line ); | |||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | 0 | push @deltas, NetApp::Snapshot::Delta->new({ | |||||||||||||||||||||||||||
| 481 | summary => $summary, | ||||||||||||||||||||||||||||
| 482 | %$delta, | ||||||||||||||||||||||||||||
| 483 | }); | ||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | 0 | return @deltas; | |||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||
| 491 | 1 | ▶ | sub _parse_snap_list { | ||||||||||||||||||||||||||
|
Subroutine
_parse_snap_list: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 494 | 1 | my $line = shift; | |||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 1 | $line =~ m{ ^ \s* \d+% \s+ \( \s* | |||||||||||||||||||||||||||
| 497 | (\d+) | ||||||||||||||||||||||||||||
| 498 | % \) \s+ \d+% \s+ \( \s* | ||||||||||||||||||||||||||||
| 499 | (\d+) | ||||||||||||||||||||||||||||
| 500 | % \) \s+ | ||||||||||||||||||||||||||||
| 501 | ( \w+ \s+ \d+ \s+ \d+ : \d+ ) | ||||||||||||||||||||||||||||
| 502 | \s+ | ||||||||||||||||||||||||||||
| 503 | (\S+) }x; | ||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||
| 505 | return { | ||||||||||||||||||||||||||||
| 506 | 1 | used => $1, | |||||||||||||||||||||||||||
| 507 | total => $2, | ||||||||||||||||||||||||||||
| 508 | date => $3, | ||||||||||||||||||||||||||||
| 509 | name => $4, | ||||||||||||||||||||||||||||
| 510 | }; | ||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | 1 | 1; | |||||||||||||||||||||||||||