# # Copyright (c) 2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::Fiji =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Fiji. A related class is L, which represents access to an ONTAP Fiji. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Fiji element are the attributes of the Fiji ComponentState. =over =item C<< node >> =item C<< filter >> =item C<< slot >> =item C<< nvram >> =item C<< FIJI_test_is_true >> =item C<< count >> =item C<< status >> =item C<< maxcount >> =back =cut package NACL::CS::Fiji; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw (_dump_one 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 [ scalar => 'node', scalar => 'filter', scalar => 'slot', scalar => 'nvram', scalar => 'FIJI_test_is_true', scalar => 'count', scalar => 'status', scalar => 'maxcount', ]; =head1 METHODS =head2 fetch my $Fiji_state = NACL::CS::Fiji->fetch(command_interface => $ci, ...); my @Fiji_states = NACL::CS::Fiji->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. Invokes "fiji show", "fiji test_is_true", "fiji dump" commands for 7Mode/Nodescope CLI. =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_7mode_cli', interface => 'CLI', set => '7Mode|Nodescope', }, ], exception_text => 'No matching debug fault injection(s) found' ); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub fetch sub _fetch_7mode_cli { $Log->enter() if $may_enter; my ( $pkg, @args ) = @_; my %opts = validate @args, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my ( $response_1, $response_2, $output_1, $output_2, @state_objs ); my %nodescope_override; if ($opts{command_interface}->is_cmode()) { if (defined $opts{'nodescope-node-name'}) { $nodescope_override{'nodescope-node-name'} = $opts{'nodescope-node-name'}; } } my ($response, $caught_exception); try { $response= $apiset->fiji_show(%nodescope_override); } catch NACL::APISet::Exceptions::NoMatchingEntriesException with { $caught_exception = 1; }; if ($caught_exception) { $Log->exit() if $may_exit; return; } my $output = $response->get_parsed_output(); if ($pkg->_want_any_field_of( requested_fields => $opts{requested_fields}, filter => $opts{filter}, fields_filled_by_api => [qw(fiji_test_is_true)] ) ) { $response_1 = $apiset->fiji_test_is_true(%nodescope_override); $output_1 = $response_1->get_parsed_output(); } ## end if ( $pkg->_want_any_field_of...) if ($pkg->_want_any_field_of( requested_fields => $opts{requested_fields}, filter => $opts{filter}, fields_filled_by_api => [qw(count status maxcount)] ) ) { $response_2 = $apiset->fiji_dump(%nodescope_override); $output_2 = $response_2->get_parsed_output(); } ## end if ( $pkg->_want_any_field_of...) my $node = $opts{command_interface}->node(); foreach my $row (@$output) { my $obj; $obj = $pkg->new( node => $node, 'command_interface' => $opts{command_interface} ); $obj->filter( $row->{filter} ); $obj->slot( $row->{slot} ); $obj->maxcount( $row->{maxcount} ); if ( $row->{nvram} ) { $obj->nvram( $row->{nvram} ); } if ( ref $output_1 ) { $obj->FIJI_test_is_true( $output_1->[0]->{FIJI_test_is_true} ); } if ( ref $output_2 ) { foreach my $_obj ( @{$output_2} ) { # To get correct count & status for right filter match the slot. next if ($obj->{slot} != $_obj->{slot_number}); $obj->count( $_obj->{count} ) if ( exists $_obj->{count} ); $obj->status( $_obj->{status} ) if ( exists $_obj->{status} ); $obj->maxcount( $_obj->{maxcount} ) if ( exists $_obj->{maxcount} ); last if ( $obj->count_isset() && $obj->status_isset() ); } } ## end if ( ref $output_2 ) push @state_objs, $obj; } ## end foreach my $row (@$output) $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_7mode_cli 1;