# # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary EventStatus ComponentState Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::EventStatus =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP EventStatus. A related class is L, which represents access to an ONTAP EventStatus. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the EventStatus element are the attributes of the EventStatus ComponentState. =over =item C<< "last_time_occurred" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "messagename" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: <>@values 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "last_time_processed" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "num_suppressed_since_last" >> Filled in for CMode CLI and CMode ZAPI. Maps to: CM ZAPI: $value =item C<< "change_since" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "last_day_histogram" >> *last_day_histogram (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $last_day_histogram = $obj->last_day_histogram(); # $last_day_histogram contains a reference to the array of values my @last_day_histogram = $obj->last_day_histogram(); # @last_day_histogram 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 => { last_day_histogram = [ value1, value2...] } Filled in for CMode CLI and CMode ZAPI. Maps to: CM ZAPI: @values =item C<< "indications" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "severity" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "num_timer_suppressed" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "num_autosuppressed" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "accumulated_bytes" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "ischatter" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "last_hour_histogram" >> *last_hour_histogram (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $last_hour_histogram = $obj->last_hour_histogram(); # $last_hour_histogram contains a reference to the array of values my @last_hour_histogram = $obj->last_hour_histogram(); # @last_hour_histogram 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 => { last_hour_histogram = [ value1, value2...] } Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: @values =item C<< "probability" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "num_dup_suppressed" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "num_rate_limited" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "last_time_dropped" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "stat_starting_time" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: $value =item C<< "drops" >> Filled in for CMode CLI/ZAPI and 7Mode CLI. Maps to: CM ZAPI: $value 7M CLI: For "filter": Applicable, Filtering will be done by Components. For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "last_week_histogram" >> *last_week_histogram (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $last_week_histogram = $obj->last_week_histogram(); # $last_week_histogram contains a reference to the array of values my @last_week_histogram = $obj->last_week_histogram(); # @last_week_histogram 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 => { last_week_histogram = [ value1, value2...] } Filled in for CMode CLI and CMode ZAPI. Maps to: CM ZAPI: @values =item C<< num_logger_dropped >> Number of Drops by Logger Filled in for CMode CLI. =back =cut package NACL::CS::EventStatus; use strict; use warnings; use Params::Validate qw(validate); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use base 'NACL::CS::ComponentState::ONTAP'; use NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use Class::MethodMaker [ scalar => 'last_time_occurred', scalar => 'messagename', scalar => 'node', scalar => 'last_time_processed', scalar => 'num_suppressed_since_last', scalar => 'change_since', array => 'last_day_histogram', scalar => 'indications', scalar => 'severity', scalar => 'num_timer_suppressed', scalar => 'num_autosuppressed', scalar => 'accumulated_bytes', scalar => 'ischatter', array => 'last_hour_histogram', scalar => 'probability', scalar => 'num_dup_suppressed', scalar => 'num_rate_limited', scalar => 'last_time_dropped', scalar => 'stat_starting_time', scalar => 'drops', array => 'last_week_histogram', scalar => 'num_logger_dropped', ]; =head1 METHODS =head2 fetch my $EventStatus_state = NACL::CS::EventStatus->fetch(command_interface => $ci, ...); my @EventStatus_states = NACL::CS::EventStatus->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, 7Mode CLI. Invokes "ems-status-get-iter" API for CMode ZAPI. Invokes "ems event status" command for 7Mode 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_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, { method => '_fetch_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], show_cmd => 'event status show', exception_text => 'No matching event status(s) found' ); $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 => 'event_status_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_7mode_cli { 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 $node = $opts{command_interface}->node(); my %command_opts; my @state_objs; my $response = $apiset->ems_event_status(%command_opts); my $ems_output = $response->get_parsed_output(); foreach my $row (@{$ems_output}) { my $obj = $pkg->new(command_interface => $opts{command_interface}); my $state_fields = {}; $state_fields->{'last_time_occurred'} = $row->{'last_time'}; $state_fields->{'severity'} = $row->{'priority'}; $state_fields->{'num_timer_suppressed'} = $row->{'timer-suppressed'}; $state_fields->{'num_autosuppressed'} = $row->{'autosuppressed'}; $state_fields->{'num_dup_suppressed'} = $row->{'dup-suppressed'}; $state_fields->{'messagename'} = $row->{'eventname'}; $state_fields->{'indications'} = $row->{'indications'}; $state_fields->{'drops'} = $row->{'drops'}; $state_fields->{'node'} = $node; $obj->_set_fields(row => $state_fields); push @state_objs, $obj; } ## end foreach my $row ( @{$ems_output... return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my @states = $pkg->SUPER::_fetch_cmode_zapi( @_, api => "ems_status_get_iter", copy => [ qw(node indications drops last-time-occurred last-time-dropped last-time-processed stat-starting-time change-since num-autosuppressed num-rate-limited num-timer-suppressed severity num-dup-suppressed num-suppressed-since-last accumulated-bytes probability) ], map => { "last-day-histogram" => [ make_zapi_array('last-day-histogram'), make_zapi_skip('integer'), ], "last-hour-histogram" => [ make_zapi_array('last-hour-histogram'), make_zapi_skip('integer'), ], "last-week-histogram" => [ make_zapi_array('last-week-histogram'), make_zapi_skip('integer'), ], "messagename" => ['message-name'], "ischatter" => ['is-chatter'], }, ); $Log->exit() if $may_exit; return @states; } ## end sub _fetch_cmode_zapi 1;