# $Id$ # # Copyright (c) 2001-2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary SystemNodeAutosupportDestinations ComponentState Module ## @author dl-nacl-dev@netapp.com, benjaram@netapp.com ## @status shared ## @pod here =head1 NAME NACL::CS::SystemNodeAutosupportDestinations =head1 DESCRIPTION C is a derived class of L. It represents the state of an ONTAP SystemNodeAutosupportDestinations. A related class is L, which represents access to an ONTAP SystemNodeAutosupportDestinations. =head1 ATTRIBUTES The individual pieces of data that are part of the state of the SystemNodeAutosupportDestinations element are the attributes of the SystemNodeAutosupportDestinations ComponentState. =over =item C<< "node" >> Filled in for CMode CLI/ZAPI Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: $value =item C<< "destinations" >> (Array) Note that for array fields, the accessor method can be invoked in either scalar or list context. my $destinations = $obj->destinations(); # $destinations contains a reference to the array of values my @destinations = $obj->destinations(); # @destinations contains the array of values Filled in for CMode CLI/ZAPI Maps to: CMode ZAPI: For "requested_fields", "filter" and Output mapping: @values =back =cut package NACL::CS::SystemNodeAutosupportDestinations; 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 NACL::CS::ComponentState::ZapiSkip qw(make_zapi_skip); use NACL::CS::ComponentState::ZapiArray qw(make_zapi_array); use base 'NACL::CS::ComponentState::ONTAP'; use Class::MethodMaker [ scalar => 'node', array => 'destinations', ]; =head1 METHODS =head2 fetch my $SystemNodeAutosupportDestinations_state = NACL::CS::SystemNodeAutosupportDestinations->fetch(command_interface => $ci, ...); my @SystemNodeAutosupportDestinations_states = NACL::CS::SystemNodeAutosupportDestinations->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-destinations-get-iter" API for CMode ZAPI. Invokes "autosupport destinations 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 destinations show', exception_text => 'No matching system node autosupport destinations(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_destinations_show'); $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; return $pkg->SUPER::_fetch_cmode_zapi( @_, api => "autosupport_destinations_get_iter", map => { 'node' => ['node-name'], 'destinations' => [make_zapi_array('destinations'), make_zapi_skip('string'),], }, ); $Log->exit() if $may_exit; } ## end sub _fetch_cmode_zapi 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 = delete $opts{apiset}; delete $opts{filter}; my @state_objs; my $response = $apiset->autosupport_destinations_show(); my $output = $response->get_parsed_output(); my $row = $output->[0]; my @destinations; my $count = 0; my $final_attributes; foreach my $key (%$row) { push(@destinations, $row->{$key}); $final_attributes->{'destinations'}->[$count] = $destinations[$count]; $count++; } my $obj = $pkg->new(command_interface => $command_interface); $obj->_set_fields(row => $final_attributes); push @state_objs, $obj; return @state_objs; } ## end sub _fetch_7mode_cli 1;