# # Copyright (c) 2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Common methods for EventLog and Eventlog CS files ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here package NACL::CS::_Mixins::EventLog; use strict; use warnings; BEGIN { use Exporter qw(import); our @EXPORT_OK = qw(_fetch_cmode_cli _extra_fetch_validate_spec); our %EXPORT_TAGS = ('all' => \@EXPORT_OK); } use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NATE::BaseException qw(:try); use NACL::C::Exceptions::TimeNotSynchronised; use NACL::CS::ClusterDate; use Params::Validate qw(SCALAR); sub _fetch_cmode_cli { $Log->enter(); my ($pkg, %opts) = @_; my @state_objs; my ($done, $tries); my $base_class = $pkg->base_class(); my $super_fetch_cm_cli = $base_class . '::_fetch_cmode_cli'; while (!$done) { try { @state_objs = $pkg->$super_fetch_cm_cli(%opts, api => 'event_log_show',); $done = 1; } catch NACL::APISet::Exceptions::ResponseException with { my $exception = shift; my $time_exception = 'NACL::C::Exceptions::TimeNotSynchronised'; if ($time_exception->detect(exception => $exception)) { $Log->warn('Time not synchronised across the nodes of the ' . 'cluster; see burt 609614 for details. Note that ' . 'the time across the nodes of the cluster can be ' . "temporarily out-of-sync for the following reasons:\n" . "1. Reboot\n" . "2. Takeover\n" . '3. The date being modified, such as through cluster ' . " date modify (this causes NTPd to be restarted)\n" ); # Not adding this to gather_diagnostics() because we want this # to be shown for every retry, not just when it eventually # throws the exception. $Log->comment('Here are the times on the nodes of the cluster:'); try { NACL::CS::ClusterDate->fetch( command_interface => $opts{command_interface}); } otherwise {}; if (++$tries > $opts{nacl_retry_count}) { $Log->exit(); $time_exception->convert_and_throw( 'exception' => $exception, 'api' => 'event_log_show', 'command_interface' => $opts{'command_interface'}, ); } else { $Log->comment('We shall attempt snoozing and retrying ' . '(hopefully this will allow the times across the ' . 'nodes to get synchronised)'); Tharn::snooze($opts{nacl_sleep_time}); } } else { $Log->exit(); $exception->throw(); } }; } $Log->exit(); return @state_objs; } sub _extra_fetch_validate_spec { return ( nacl_retry_count => {type => SCALAR, default => 60}, nacl_sleep_time =>{type => SCALAR, default => 30}, ); } 1;