# $Id$ # # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeDate ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeDate =head1 DESCRIPTION B (See https://wikid.netapp.com/w/Cluster_QoS/SN_QOS_NTP_FS.) C is a derived class of L. It represents the state of an ONTAP SystemNodeDate. A related class is L, which represents access to an ONTAP SystemNodeDate. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeDate element are the attributes of the SystemNodeDate ComponentState. =over =item C<< "utc_date" >> =item C<< "alt_date" >> =item C<< "timezone" >> =item C<< "utcdateandtime" >> =item C<< "date" >> =item C<< "dateandtime" >> =item C<< "node" >> =back =cut package NACL::CS::SystemNodeDate; use strict; use warnings; use Params::Validate qw(validate validate_with); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use NACL::ComponentUtils qw(Dumper _dump_one enumerate_month); use NACL::CS::ClusterDate; use NACL::Exceptions::NoElementsFound qw(:try); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'utc_date', scalar => 'alt_date', scalar => 'timezone', scalar => 'utcdateandtime', scalar => 'date', scalar => 'dateandtime', scalar => 'node', ]; =head1 METHODS =head2 fetch my $SystemNodeDate_state = NACL::CS::SystemNodeDate->fetch(command_interface => $ci, ...); my @SystemNodeDate_states = NACL::CS::SystemNodeDate->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, @args) = @_; my %opts = validate_with( params => \@args, spec => {command_interface => $pkg->_ontap_ci_validate_spec()}, allow_extra => 1 ); my @state_objs; my $ci = $opts{command_interface}; if ($ci->is_cmode) { $Log->warn("Your build has cluster QoS changes for NTP.\n" . 'Date and time should be set cluster-wide. Switch to ' . 'using NACL::CS::ClusterDate->fetch()'); @state_objs = NACL::CS::ClusterDate->fetch(%opts); } else { @state_objs = $pkg->SUPER::fetch( %opts, show_cmd => 'system node date show', choices => [ { method => '_fetch_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_fetch_7mode_cli', interface => 'CLI', set => '7Mode', }, ], exception_text => 'No matching system node date(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 => 'system_node_date_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 = delete $opts{apiset}; my $filter = delete $opts{filter}; my @values; my @state_objs; my $response = $apiset->date(); my $output = $response->get_parsed_output(); my $Node = $opts{command_interface}->node(); foreach my $row (@$output) { my $obj = $pkg->new(node => $Node); my %hash = (); my $time; @values = split(/\s+/, $$row{'system_day_date'}); my $month_string = $values[1]; my $DD = $values[2]; my $HHMMSS = $$row{'system_current_time_without_timezone'}; my $YYYY = $$row{'system_year'}; # Turn the month string into the MM format my $MM = $pkg->enumerate_month(month => $month_string); $hash{'date'} = "$MM/$DD/$YYYY $HHMMSS"; $hash{'timezone'} = $$row{'timezone'}; if ($hash{'timezone'} eq "PDT") { $hash{'timezone'} = "PST8PDT"; } $hash{'command_interface'} = $opts{'command_interface'}; $obj->_set_fields(row => \%hash); push @state_objs, $obj; } ## end foreach my $row (@$output) return @state_objs; } ## end sub _fetch_7mode_cli 1;