# # Copyright (c) 2001-2011 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Antivirus ComponentState Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com, benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::Antivirus =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP Antivirus. A related class is L, which represents access to an ONTAP Antivirus. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the Antivirus element are the attributes of the Antivirus ComponentState. =over =item C<< "last_update_reason" >> Filled in for CMode CLI. =item C<< "internal_version" >> Filled in for CMode CLI. =item C<< "target_nodes" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $target_nodes = $obj->target_nodes(); # $target_nodes contains a reference to the array of values my @target_nodes = $obj->target_nodes(); # @target_nodes contains the array of values Filled in for CMode CLI. =item C<< "version" >> Filled in for CMode CLI. =item C<< "last_update" >> Filled in for CMode CLI/ZAPI. Maps to: CM ZAPI: last-update-time =item C<< "auto_update" >> Filled in for CMode CLI. =item C<< "state" >> Filled in for CMode CLI. =item C<< "target_num_active" >> Filled in for CMode CLI. =item C<< "update_schedule" >> Filled in for CMode CLI. =item C<< "current_nodes" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $current_nodes = $obj->current_nodes(); # $current_nodes contains a reference to the array of values my @current_nodes = $obj->current_nodes(); # @current_nodes contains the array of values Filled in for CMode CLI. =item C<< "current_num_active" >> Filled in for CMode CLI. =item C<< "vendor" >> Filled in for CMode CLI. =back =cut package NACL::CS::Antivirus; 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 => 'last_update_reason', scalar => 'internal_version', array => 'target_nodes', scalar => 'version', scalar => 'last_update', scalar => 'auto_update', scalar => 'state', scalar => 'target_num_active', scalar => 'update_schedule', array => 'current_nodes', scalar => 'current_num_active', scalar => 'vendor', ]; =head1 METHODS =head2 fetch my $Antivirus_state = NACL::CS::Antivirus->fetch(command_interface => $ci, ...); my @Antivirus_states = NACL::CS::Antivirus->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 "av-get-version-info" 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_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], exception_text => 'No matching antivirus(s) found', is_singleton => 1, show_cmd => 'antivirus show', ); $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 => 'antivirus_show', is_singleton => 1 ); $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_cli sub _fetch_cmode_zapi { $Log->enter() if $may_enter; my $pkg = shift; my %opts = validate @_, $pkg->_fetch_backend_validate_spec(); my $apiset = $opts{apiset}; my @state_objs; my $antivirus_response1 = $apiset->av_get_version_info(); my $antivirus_output1 = $antivirus_response1->get_parsed_output(); my $antivirus_response2 = $apiset->av_get_engine_info(); my $antivirus_output2 = $antivirus_response2->get_parsed_output(); my $state_fields; foreach my $row (@{$antivirus_output1}) { $state_fields = $pkg->_zapi_hash_copy( source => $row, map => ['last-update-time' => 'last-update',], ); } foreach my $row (@{$antivirus_output2}) { my %fields = %$state_fields; $fields{'vendor'} = $row->{'vendor'}; if ($row->{'is-enabled'} =~ /true/) { $fields{'state'} = 'on'; } elsif ($row->{'is-enabled'} =~ /false/) { $fields{'state'} = 'off'; } my $obj = $pkg->new(command_interface => $opts{command_interface}); $obj->_set_fields(row => \%fields); push @state_objs, $obj; } $Log->exit() if $may_exit; return @state_objs; } ## end sub _fetch_cmode_zapi 1;