# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeEnvironmentSensors ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeEnvironmentSensors =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemNodeEnvironmentSensors. A related class is L, which represents access to an ONTAP SystemNodeEnvironmentSensors. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeEnvironmentSensors element are the attributes of the SystemNodeEnvironmentSensors ComponentState. =over =item C<< "crit_low" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "fru" >> =item C<< "value" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "inactive" >> =item C<< "discrete_value" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "name" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "node" >> =item C<< "state" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "index" >> =item C<< "warn_low" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "warn_hi" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "type" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "crit_hi" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "discrete_state" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =item C<< "units" >> Maps to: CMode ZAPI: $value Filled in for CMode CLI/ZAPI =back =cut package NACL::CS::SystemNodeEnvironmentSensors; use strict; use warnings; use Params::Validate qw(validate); use NACL::ComponentUtils qw(_dump_one); 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 => 'crit_low', scalar => 'fru', scalar => 'value', scalar => 'inactive', scalar => 'discrete_value', scalar => 'name', scalar => 'node', scalar => 'state', scalar => 'index', scalar => 'warn_low', scalar => 'warn_hi', scalar => 'type', scalar => 'crit_hi', scalar => 'discrete_state', scalar => 'units', ]; =head1 METHODS =head2 fetch my $SystemNodeEnvironmentSensors_state = NACL::CS::SystemNodeEnvironmentSensors->fetch(command_interface => $ci, ...); my @SystemNodeEnvironmentSensors_states = NACL::CS::SystemNodeEnvironmentSensors->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 "environment-sensors-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; 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', }, ], exception_text => 'No matching system node environment sensors(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_environment_sensors_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 @state_objs; my $apiset = delete $opts{apiset}; my $command_interface = delete $opts{command_interface}; my %copy_filter = %{$opts{filter}}; my @copy_requested_fields = @{$opts{requested_fields}}; my $deleted_filter = $pkg->_remove_relational_regex_filters( filter => \%copy_filter, requested_fields => \@copy_requested_fields ); my $filter = \%copy_filter; my $requested_fields = \@copy_requested_fields; my $response = $apiset->environment_status_chassis('list-sensors' => "1"); my $output = $response->get_parsed_output(); $output = $output->[0]->{'list_sensors'}; foreach my $list_output (@{$output}) { my $target = $pkg->_hash_copy( source => $list_output, copy => [qw( state )], map => { 'critical_low' => 'crit_low', 'sensor_name' => 'name', 'warning_low' => 'warn_low', 'warning_high' => 'warn_hi', 'critical_high' => 'crit_hi', }, ); my $obj = $pkg->new(command_interface => $command_interface,); $obj->_set_fields(row => $target); push @state_objs, $obj; } ## end foreach my $list_output (@$output) return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my ($pkg, @args) = @_; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @args, api => 'environment-sensors-get-iter', map => { 'crit-low' => 'critical-low-threshold', 'crit-hi' => 'critical-high-threshold', 'state' => 'threshold-sensor-state', 'value' => 'threshold-sensor-value', 'discrete-state' => 'discrete-sensor-state', 'discrete-value' => 'discrete-sensor-value', 'node' => 'node-name', 'name' => 'sensor-name', 'type' => 'sensor-type', 'units' => 'value-units', 'warn-hi' => 'warning-high-threshold', 'warn-low' => 'warning-low-threshold', }, ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;