# # Copyright (c) 2013-2016 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Common methods for the VolumeQuota ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here package NACL::CS::_Mixins::VolumeQuota; use strict; use warnings; use NATE::Log qw(log_global); use Params::Validate qw(HASHREF SCALAR validate_with); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); BEGIN { use Exporter qw(import); our @EXPORT_OK = qw( _common_snmp_map _common_zapi_map _common_zapi_copy _check_flexgroup_constituent_like_volume ); our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); } sub _common_snmp_map { $Log->enter() if $may_enter; my $map = { volume => 'qvStateName', vserver => 'qvStateVserver', state => 'qvStateStat', 'scan-status' => 'qvStateInitPercent', }; $Log->exit() if $may_exit; return $map; } sub _common_zapi_map { $Log->enter() if $may_enter; my $map = { "state" => ['status'], "scan-status" => ['percent-complete'], "last-error" => ['reason'], "sub-status" => ['substatus'], "quota-status" => ['quota-error-msgs'], }; $Log->exit() if $may_exit; return $map; } sub _common_zapi_copy { $Log->enter() if $may_enter; my $copy = [qw(vserver volume)]; $Log->exit() if $may_exit; return $copy; } sub _check_flexgroup_constituent_like_volume { $Log->enter() if $may_enter; my $pkg_or_obj = shift; my %opts = validate_with( params => \@_, spec => { interface_description => { type => SCALAR, }, _method => { type => SCALAR, }, }, allow_extra => 1, ); my $volume = defined($opts{filter}) ? $opts{filter}->{volume} : $opts{volume}; my $ifdesc = $opts{interface_description}; my $method = $opts{_method}; if (defined($volume) && !$pkg_or_obj->_check_relational_regex_filter(filter_value => $volume) && ($volume =~ /__\d{4}$/)) { $Log->exit() if $may_exit; NACL::Exceptions::InvalidChoice->throw("Disallowing ${ifdesc} " . "implementation of ${method} because it looks like " . "the desired volume might be a FlexGroup constituent.\n"); } $Log->exit() if $may_exit; } 1;