# # Copyright (c) 2001-2010 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary StorageErrors ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::StorageErrors =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP StorageErrors. A related class is L, which represents access to an ONTAP StorageErrors. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the StorageErrors element are the attributes of the StorageErrors ComponentState. =over =item C<< "error_type" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "error-type" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "error-type" in the output of CLI "storage_errors_show" =item C<< "disk" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "disk-name" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "disk" in the output of CLI "storage_errors_show" =item C<< "errors" >> (Array) Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "errors" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "errors" in the output of CLI "storage_errors_show" =item C<< "uid" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "uid" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "uid" in the output of CLI "storage_errors_show" =item C<< "serial_number" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "serial-number" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "serial-number" in the output of CLI "storage_errors_show" =item C<< "node" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "node" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "node" in the output of CLI "storage_errors_show" =item C<< "error_id" >> (Array) Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "error-id" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "error-id" in the output of CLI "storage_errors_show" =item C<< "array_name" >> Filled in for CMode CLI, CMode ZAPI. CMode ZAPI: Accessible through the field "array-name" in the output of ZAPI "storage_initiator_errors_list_info" CMode CLI : Accessible through the field "array-name" in the output of CLI "storage_errors_show" =item C<< error_type_zapi >> Error Type for Zapi use (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $error_type_zapi = $obj->error_type_zapi(); # $error_type_zapi contains a reference to the array of values my @error_type_zapi = $obj->error_type_zapi(); # @error_type_zapi contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { error_type_zapi = [ value1, value2...] } Filled in for CMode CLI. =item C<< is_error >> Has an error associated possible value(s) are, true,false Filled in for CMode CLI. =item C<< error_text_list >> Error Text (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $error_text_list = $obj->error_text_list(); # $error_text_list contains a reference to the array of values my @error_text_list = $obj->error_text_list(); # @error_text_list contains the array of values If this field needs to be passed to the filter hash, the value for this field should be passed in as an arrayref # filter => { error_text_list = [ value1, value2...] } Filled in for CMode CLI. =back =cut package NACL::CS::StorageErrors; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw (_optional_scalars Dumper); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ array => 'error_type', scalar => 'count', scalar => 'disk', array => 'errors', scalar => 'uid', scalar => 'serial_number', scalar => 'node', array => 'error_id', scalar => 'array_name', array => 'error_type_zapi', scalar => 'is_error', array => 'error_text_list', ]; =head1 METHODS =head2 fetch my $StorageErrors_state = NACL::CS::StorageErrors->fetch(command_interface => $ci, ...); my @StorageErrors_states = NACL::CS::StorageErrors->fetch(command_interface => $ci, ...); (Class method) Discovers which elements are present and returns their state in ComponentState objects. Called in scalar context it returns only one state object, in list context it returns all state objects. See L for a more detailed description along with a complete explanation of the options it accepts. =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', }, ], exception_text => 'No matching storage errors(s) found', show_cmd => 'storage errors show', ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_cmode_cli { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_cli(@_, api => 'storage_errors_show'); $Log->exit() if $may_exit; return @state_objs; } ## 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 $filter = $opts{filter}; my $caught_exception; my $ci_response; my %ci_list_info_args; # Displays the storge errors engine and its configuration. try { $pkg->_hash_copy( source => $filter, target => \%ci_list_info_args, copy => [qw(array-name)], map => {'disk' => 'disk-name'} ); $ci_response = $apiset->storage_initiator_errors_list_info(%ci_list_info_args); } ## end try catch NACL::APISet::Exceptions::ResponseException with { # A caught exception indicates that the storage errors being looked for # does not exist. We catch the exception and return immediately. The # 'fetch' frontend decides whether to throw a NoElementsFound # exception based on the value of 'allow_empty' $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $ci_output = $ci_response->get_parsed_output(); $Log->debug(Dumper($ci_output)); my @state_objs; foreach my $row (@{$ci_output->[0]->{'errors'}->[0]->{'errors'}}) { my $state_fields = $pkg->_zapi_hash_copy( source => $row, source_has_extra_arrays => 1, copy => [qw(array-name node error-id error-type)], map => [ "disk" => "disk-name", "disk-uid" => "uid", "lun-serial-number" => "serial-number", "error-text" => "errors", ], ); my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => $state_fields); push @state_objs, $obj; } ## end foreach my $row ( @{ $ci_output... $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;