# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary QosWorkload ComponentState Module ## @author dl-nacl-dev@netapp.com, dl-perf-qa@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::QosWorkload =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP QosWorkload. A related class is L, which represents access to an ONTAP QosWorkload =head1 ATTRIBUTES The individual pieces of data that are part of the state of the QosWorkload element are the attributes of the QosWorkload ComponentState. =over =item C<< workload >> The name of the QoS workload element whose state is being represented. =item C<< uuid >> =item C<< class >> =item C<< wid >> =item C<< streams >> =item C<< policy >> =item C<< match_priority >> =item C<< policy_uuid >> =item C<< protocol >> Filled in for CMode CLI. =item C<< ip >> Filled in for CMode CLI. =item C<< policy_priority >> Filled in for CMode CLI. =item C<< lun >> Filled in for CMode CLI. =item C<< igroup >> Filled in for CMode CLI. =item C<< qtree >> Filled in for CMode CLI. =item C<< request_type >> Filled in for CMode CLI. =item C<< volume >> Filled in for CMode CLI. =item C<< vserver >> Filled in for CMode CLI. =item C<< min_req_size >> Filled in for CMode CLI. =item C<< wwn >> Filled in for CMode CLI. =item C<< max_req_size >> Filled in for CMode CLI. =item C<< file >> Filled in for CMode CLI. =item C<< category >> Filled in for CMode CLI. =item C<< policy_group >> Filled in for CMode CLI. =item C<< read_ahead >> Filled in for CMode CLI. =item C<< ext_cache >> Filled in for CMode CLI. =item C<< external_cache >> *External Cache Tunables Filled in for CMode CLI. =item C<< uuid_str >> Filled in for CMode CLI. =item C<< caching_policy >> Cache Tunables Filled in for CMode CLI. =back =cut package NACL::CS::QosWorkload; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Data::Dumper; use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use NACL::C::QosPolicy; use NACL::Exceptions::InvalidChoice; use Class::MethodMaker [ scalar => 'workload', scalar => 'uuid', scalar => 'class', scalar => 'wid', # CLI only scalar => 'streams', # Count of associated streams scalar => 'policy', # Policy name - not uuid scalar => 'match_priority', scalar => 'policy_uuid', scalar => 'protocol', scalar => 'ip', scalar => 'policy_priority', scalar => 'lun', scalar => 'igroup', scalar => 'qtree', scalar => 'request_type', scalar => 'volume', scalar => 'vserver', scalar => 'min_req_size', scalar => 'wwn', scalar => 'max_req_size', scalar => 'file', scalar => 'category', scalar => 'policy_group', scalar => 'read_ahead', scalar => 'ext_cache', scalar => 'external_cache', scalar => 'uuid_str', scalar => 'caching_policy', ]; =head1 METHODS =head2 fetch my $workload_state = NACL::CS::QosWorkload->fetch(command_interface=>$ci,...); my @workload_states = NACL::CS::QosWorkload->fetch(command_interface=>$ci,...); see L =over =item Exceptions =over =item C When there are no elements matching the query specified or elements of that type doesn't exist, then this exception will be thrown. =back =back =cut sub fetch { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::fetch( @_, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', check => '_check_zapi' }, ], exception_text => 'No matching qos workload(s) found', show_cmd => 'qos workload show', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _check_zapi { $Log->enter() if $may_enter; my ($pkg, %opts) = @_; my $filter = $opts{filter}; if (!defined $filter->{class}) { my $msg = "Field 'class' was not provided in the filter in the call to " . 'NACL::CS::QosWorkload->fetch().' . ' Absence of this field makes ZAPI output different than CLI. ' . 'So falling back to CLI for consistent output'; $Log->comment($msg); $Log->exit() if $may_exit; NACL::Exceptions::InvalidChoice->throw($msg); } $Log->exit() if $may_exit; } sub _fetch_cmode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my @workloads = $pkg->SUPER::_fetch_cmode_cli(%opts, api => 'qos_workload_show'); $Log->exit() if $may_exit; return @workloads; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my $requested_fields = $opts{requested_fields}; my $filter = $opts{filter}; my @workloads; @workloads = $pkg->SUPER::_fetch_cmode_zapi( @_, api => "qos-workload-get-iter", copy => [ qw(vserver category qtree volume lun file category read-ahead policy-group wid) ], map => { "workload" => ['workload-name'], "uuid" => ['workload-uuid'], "class" => ['workload-class'], }, do_not_warn_for_missing_attribute => 1 ); $Log->exit() if $may_exit; return @workloads; } ## end sub _fetch_cmode_zapi sub _update_state_objs_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; $pkg->SUPER::_update_state_objs_cmode_zapi( @args, zapi_field_translations => { hyphenate_value => [qw(class)], }, ); $Log->exit() if $may_exit; } 1;