# # Copyright (c) 2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Common methods for the VolumeFileMove and VolumeFileCopy components ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here package NACL::CS::_Mixins::VolumeFileCopyMove; use strict; use warnings; BEGIN { use Exporter qw(import); our @EXPORT_OK = qw(_common_zapi_copy _common_zapi_map _fetch_zapi_helper); our %EXPORT_TAGS = ('all' => \@EXPORT_OK); } use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Params::Validate qw(:all); sub _common_zapi_map { $Log->enter() if $may_enter; my %map = ( 'destination-dsid' => 'destination-volume-dsid', 'scanner-progress' => 'scanner-progress-bytes', 'scanner-total' => 'scanner-total-size', 'source-msid' => 'source-volume-msid', 'source-dsid' => 'source-volume-dsid', 'destination-generation' => 'destination-file-generation-id', 'scanner-paused' => 'is-scanner-paused', 'source-generation' => 'source-file-generation-id', 'source-snap-id' => 'source-volume-snap-id', 'source-vserver-id' => 'source-vserver', ); $Log->exit() if $may_exit; return wantarray ? %map : {%map}; } sub _common_zapi_copy { $Log->enter() if $may_enter; my @copy = ( qw(destination-file-path destination-fileid destination-path file-index is-destination-ready is-scanner-active is-snapshot-fenced job-uuid scanner-status source-file-path source-fileid last-failure-reason) ); $Log->exit() if $may_exit; return wantarray ? @copy : [@copy]; } sub _fetch_zapi_helper { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my $copy = $pkg->_common_zapi_copy(); my $map = $pkg->_common_zapi_map(); my $super_fetch = $pkg->base_class() . '::_fetch_cmode_zapi'; my @state_objs = $pkg->$super_fetch( @args, copy => $copy, map => $map, ); foreach my $cs (@state_objs) { # CLI values for scanner-status start with a capital letter, ZAPI is # all lower-case. Normalize here. my $scanner_status = $cs->scanner_status(); if (defined $scanner_status) { $cs->scanner_status(ucfirst $scanner_status); } } $Log->exit() if $may_exit; return @state_objs; } 1;