# # Copyright (c) 2001-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeAutosupportTrigger ComponentState Module ## @author dl-nacl-dev@netapp.com ## Added 7Mode cli support for find ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeAutosupportTrigger =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemNodeAutosupportTrigger. A related class is L, which represents access to an ONTAP SystemNodeAutosupportTrigger. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeAutosupportTrigger element are the attributes of the SystemNodeAutosupportTrigger ComponentState. =over =item C<< "noteto" >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": -noteto (Programmatic name: noteto) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "basic_default" >> (Array) Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: @values 7Mode CLI: For "filter": -basic-default (Programmatic name: basic-default) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "autosupport_message" >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": -autosupport-message (Programmatic name: autosupport-message) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "troubleshooting_additional" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $troubleshooting_additional = $obj->troubleshooting_additional(); # $troubleshooting_additional contains a reference to the array of values my @troubleshooting_additional = $obj->troubleshooting_additional(); # @troubleshooting_additional contains the array of values Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: @values 7Mode CLI: For "filter": -troubleshooting-additional (Programmatic name: troubleshooting-additional) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "node" >> Filled in for CMode CLI/ZAPI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< "time_limit" >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: $value 7Mode CLI: For "filter": -time-limit (Programmatic name: time-limit) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "additional_content" >> (Array) Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @values 7Mode CLI: For "filter": -additional-content (Programmatic name: additional-content) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "troubleshooting_default" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $troubleshooting_default = $obj->troubleshooting_default(); # $troubleshooting_default contains a reference to the array of values my @troubleshooting_default = $obj->troubleshooting_default(); # @troubleshooting_default contains the array of values Filled in for CMode CLI, 7Mode CLI. Maps to: 7Mode CLI: For "filter": -troubleshooting-default (Programmatic name: troubleshooting-default) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "to" >> Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value 7Mode CLI: For "filter": -to (Programmatic name: to) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< "basic_additional" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $basic_additional = $obj->basic_additional(); # $basic_additional contains a reference to the array of values my @basic_additional = $obj->basic_additional(); # @basic_additional contains the array of values Filled in for CMode CLI/ZAPI, 7Mode CLI. Maps to: CM ZAPI: For "requested_fields", "filter" and Output mapping: @values 7Mode CLI: For "filter": -basic-additional (Programmatic name: basic-additional) For "requested_fields", Not applicable, but the field will be populated in the CS object. =item C<< basic_subsystems >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $basic_subsystems = $obj->basic_subsystems(); $basic_subsystems contains a reference to the array of values my @basic_subsystems = $obj->basic_subsystems(); @basic_subsystems contains the array of values Filled in for CMode CLI. =item C<< troubleshooting_subsystems >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $troubleshooting_subsystems = $obj->troubleshooting_subsystems(); $troubleshooting_subsystems contains a reference to the array of values my @troubleshooting_subsystems = $obj->troubleshooting_subsystems(); @troubleshooting_subsystems contains the array of values Filled in for CMode CLI. =item C<< diagnostic_default >> Default Subsystems Reporting Diagnostic Info (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $diagnostic_default = $obj->diagnostic_default(); # $diagnostic_default contains a reference to the array of values my @diagnostic_default = $obj->diagnostic_default(); # @diagnostic_default 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 => { diagnostic_default = [ value1, value2...] } Filled in for CMode CLI. =item C<< diagnostic_additional >> Additional Subsystems Reporting Diagnostic Info (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $diagnostic_additional = $obj->diagnostic_additional(); # $diagnostic_additional contains a reference to the array of values my @diagnostic_additional = $obj->diagnostic_additional(); # @diagnostic_additional 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 => { diagnostic_additional = [ value1, value2...] } Filled in for CMode CLI. =item C<< suppress >> Suppress all occurrences of this trigger possible value(s) are, true,false Filled in for CMode CLI. =back =cut package NACL::CS::SystemNodeAutosupportTrigger; 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 NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use Class::MethodMaker [ scalar => 'noteto', array => 'basic_default', scalar => 'autosupport_message', array => 'troubleshooting_additional', scalar => 'node', scalar => 'time_limit', array => 'additional_content', array => 'troubleshooting_default', scalar => 'to', array => 'basic_additional', array => 'basic_subsystems', array => 'troubleshooting_subsystems', array => 'diagnostic_default', array => 'diagnostic_additional', scalar => 'suppress', ]; =head1 METHODS =head2 fetch my $SystemNodeAutosupportTrigger_state = NACL::CS::SystemNodeAutosupportTrigger->fetch(command_interface => $ci, ...); my @SystemNodeAutosupportTrigger_states = NACL::CS::SystemNodeAutosupportTrigger->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 "autosupport-trigger-get-iter" API for CMode ZAPI. Invokes "autosupport trigger show" 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 => 'system node autosupport trigger show', exception_text => 'No matching system node autosupport trigger(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_autosupport_trigger_show'); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_7mode_cli { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $command_interface = delete $opts{command_interface}; my $apiset = $opts{apiset}; my %copy_filter = %{$opts{filter}}; my @copy_requested_fields = @{$opts{requested_fields}}; my $filter = \%copy_filter; my $requested_fields = \@copy_requested_fields; my $req_field_filter; $req_field_filter->{'requested_fields'} = $requested_fields; $req_field_filter->{'filter'} = \%copy_filter; my @state_objs; my %trigger_status; foreach my $key (%{$opts{filter}}) { if ($key eq "node") { next; } else { $trigger_status{$key} = $req_field_filter->{'filter'}->{$key}; } } ## end foreach my $key ( %{ $opts{... my $response = $apiset->autosupport_trigger_show(%trigger_status); my $output = $response->get_parsed_output(); my $final_attributes; foreach my $row (@$output) { $final_attributes = $pkg->_hash_copy( source => $row, copy => [qw(to noteto )], map => { 'autosupport-message' => 'autosupport_message', 'basic-default' => 'basic_default', 'troubleshooting-default' => 'troubleshooting_default', 'additional-content' => 'additional_content', 'basic-additional' => 'basic_additional', 'troubleshooting-additional' => 'troubleshooting_additional', 'time-limit' => 'time_limit', }, ); my $obj = $pkg->new(command_interface => $command_interface); $obj->_set_fields(row => $final_attributes); push @state_objs, $obj; } ## end foreach my $row (@$output) return @state_objs; } ## end sub _fetch_7mode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my @state_objs = $pkg->SUPER::_fetch_cmode_zapi( @_, api => "autosupport_trigger_get_iter", copy => [qw(time-limit)], map => { 'autosupport-message' => ['trigger'], 'node' => ['node-name'], 'noteto' => ['noteto-enabled'], 'to' => ['to-enabled'], 'basic-default' => [ make_zapi_array('basic-default'), make_zapi_skip('asup-subsystems') ], 'troubleshooting-default' => [ make_zapi_array('troubleshooting-default'), make_zapi_skip('asup-subsystems') ], 'additional-content' => [ make_zapi_array('additional-content'), make_zapi_skip('asup-content-type') ], 'basic-additional' => [ make_zapi_array('basic-additional'), make_zapi_skip('asup-subsystems') ], 'troubleshooting-additional' => [ make_zapi_array('troubleshooting-additional'), make_zapi_skip('asup-subsystems') ], }, ); my %enabled_boolean_hash = ('true' => 'enabled', 'false' => 'disabled'); foreach my $state_obj (@state_objs) { foreach my $boolean_field (qw(to noteto)) { my $isset = "${boolean_field}_isset"; if ($state_obj->$isset() && exists $enabled_boolean_hash{$state_obj->$boolean_field()}) { my $value = $enabled_boolean_hash{$state_obj->$boolean_field()}; $state_obj->$boolean_field($value); } } } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;