# # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary JobHistory ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::JobHistory =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP JobHistory. A related class is L, which represents access to an ONTAP JobHistory. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the JobHistory element are the attributes of the JobHistory ComponentState. =over =item C<< "sort_time" >> Filled in for CMode CLI. =item C<< "node" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "tid" >> Filled in for CMode CLI. =item C<< "record" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "pid" >> Filled in for CMode CLI. =item C<< "error_text" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "starttime" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "logtime" >> Filled in for CMode CLI. =item C<< "endtime" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "id" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "jobuuid" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "code" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "vserver" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "name" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "description" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "completion" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "error_code" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "process" >> Filled in for CMode CLI. =item C<< "username" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "event_type" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< "event_time" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: For "filter", "requested_fields" and Output mapping: $value =item C<< progress >> Filled in for CMode CLI/ZAPI. =back =cut package NACL::CS::JobHistory; use strict; use warnings; use Params::Validate qw(validate validate_with); use NACL::ComponentUtils qw(_dump_one _retry_logic _retry_spec); 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 Class::MethodMaker [ scalar => 'sort_time', scalar => 'node', scalar => 'tid', scalar => 'record', scalar => 'pid', scalar => 'error_text', scalar => 'starttime', scalar => 'logtime', scalar => 'endtime', scalar => 'id', scalar => 'jobuuid', scalar => 'code', scalar => 'vserver', scalar => 'name', scalar => 'description', scalar => 'completion', scalar => 'error_code', scalar => 'process', scalar => 'username', scalar => 'event_type', scalar => 'event_time', scalar => 'progress', ]; =head1 METHODS =head2 fetch my $JobHistory_state = NACL::CS::JobHistory->fetch(command_interface => $ci, ...); my @JobHistory_states = NACL::CS::JobHistory->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. Supports CMode CLI/ZAPI. Invokes "job-history-get-iter" API for CMode ZAPI. =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; # validate nacl_retry_count option my %opts = validate_with( params => \@_, spec => {nacl_retry_count => $pkg->_retry_spec(),}, allow_extra => 1 ); # NOTE: We shouldn't change the structure of choices hash in this front # end code as the component metrics tool is dependent on this pattern # choices => {hash_structure} for identifying the modes and interfaces # supported by this component. %opts = ( %opts, choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], show_cmd => 'job history show', exception_text => 'No matching job history(s) found' ); my $retry = delete $opts{nacl_retry_count}; my @state_objs = $pkg->_retry_logic( method => 'SUPER::fetch', args => \%opts, retry => $retry, exception_type => 'NACL::Exceptions::NoElementsFound' ); $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 => 'job_history_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, @args) = @_; my @states = $pkg->SUPER::_fetch_cmode_zapi( @args, api => "job_history_get_iter", map => { "node" => ['job-node'], "record" => ['log-id'], "id" => ['job-id'], "endtime" => ['job-end-time'], "starttime" => ['job-start-time'], "name" => ['job-name'], "description" => ['job-description'], "code" => ['job-status-code'], "completion" => ['job-completion'], "jobuuid" => ['job-uuid'], "event-type" => ['job-event-type'], "event-time" => ['job-event-time'], "error-code" => ['job-manager-error-code'], "error-text" => ['job-manager-error-text'], "vserver" => ['job-vserver'], "username" => ['job-username'], progress => 'job-progress', }, ); $Log->exit() if $may_exit; return @states; } ## 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 => { ucfirst => [qw(event-type)], }, ); $Log->exit() if $may_exit; } sub _invoke { $Log->enter() if $may_enter; my ($pkg_or_obj, %opts) = @_; my $method = delete $opts{method}; my @response = $pkg_or_obj->$method(%opts); $Log->exit() if $may_exit; return @response; } 1;