# $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 NetworkFcpAdapter Component Module (auto-generated by CGT) ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here =head1 NAME NACL::C::NetworkFcpAdapter =head1 DESCRIPTION C is a derived class of L. It represents access to an ONTAP NetworkFcpAdapter. A related class is L, which represents the past state of an ONTAP NetworkFcpAdapter. =head1 ATTRIBUTES =head2 command_interface See L =head2 adapter =head2 node =cut package NACL::C::NetworkFcpAdapter; use strict; use warnings; use NACL::CS::NetworkFcpAdapter; use NACL::ComponentUtils qw (_optional_scalars Dumper); use base 'NACL::C::Component::ONTAP'; use Params::Validate qw(validate validate_with SCALAR ARRAYREF); use NATE::Exceptions::Argument; use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); =head1 METHODS =head2 new my $NetworkFcpAdapter = NACL::C::NetworkFcpAdapter->new( command_interface => $ci, 'adapter' => $adapter, 'node' => $node, ); Return a new NetworkFcpAdapter component object with the given attributes. =cut use Class::MethodMaker [ scalar => 'adapter', scalar => 'node', ]; sub isa { $Log->enter() if $may_enter; my ($pkg_or_obj, $kind) = @_; my $isa = $pkg_or_obj->_build_isa( kind => $kind, alias => 'NACL::C::FcpAdapter' ); $Log->exit() if $may_exit; return $isa; } =head2 find my $NetworkFcpAdapter_obj = NACL::C::NetworkFcpAdapter->find(command_interface => $ci, ...); my @NetworkFcpAdapter_objs = NACL::C::NetworkFcpAdapter->find(command_interface => $ci, ...); (Class method) A constructor of sorts, which discovers which elements are present (by interacting with the given command interface). In an array context it creates a component object for each present element and returns them. In a scalar context it creates a component object for just one element. This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. Uses a CMode CLI/ZAPI APISet. =head2 state my NetworkFcpAdapter_state = $NetworkFcpAdapter_obj->state(); (Instance method) Fetch the current state of the element associated with this component, and return a Component State object corresponding to this component (calling this on NACL::C::NetworkFcpAdapter would return a NACL::CS::NetworkFcpAdapter object) This method is generally not implemented in individual components. The base class (L provides an implementation. See for a more detailed description along with explanation of all the options accepted. Uses a CMode CLI/ZAPI APISet. =cut =head2 stats my $method_obj = NACL::C::NetworkFcpAdapter->stats(command_interface => $ci, [ filter => { %filter } ,] [ requested_fields => [ @req_fields ]); or my $method_objs = NACL::C::NetworkFcpAdapter->stats(command_interface => $ci, [ filter => { %filter } ,] [ requested_fields => [ @req_fields ]); (Class method) This method returns objects of the type L. This method accepts all the parameters accepted by L (requested_fields, filter, allow_empty) and has all of the other properties of fetch methods (callable in scalar or list context, throws a NoElementsFound exception if no matching elements are found) =cut sub stats { $Log->enter() if $may_enter; my $pkg = shift; require NACL::CS::NetworkFcpAdapterStats; my @state_objs = NACL::CS::NetworkFcpAdapterStats->fetch(@_); $Log->exit() if $may_exit; return wantarray ? @state_objs : $state_objs[0]; } ## end sub stats =head2 modify NACL::C::NetworkFcpAdapter->modify( command_interface => $ci, 'adapter' => $adapter, 'node' => $node, ...); or $NetworkFcpAdapter_obj->modify(...); (Class or instance method) This method is used to modify the fcp adapter settings. Uses a CMode CLI/ZAPI APISet. Invokes "fcp-adapter-config-up" API for CMode ZAPI if state is up. Invokes "fcp-adapter-config-down" API for CMode ZAPI if state is down. Invokes "fcp-adapter-set-speed" API for CMode ZAPI if speed is defined. =over =item Options =over =item C<< command_interface => $command_interface >> (Required for class method, Not Applicable for instance method) See L =item C<< apiset_must => $ruleset >> (Optional) See L =item C<< apiset_should => $ruleset >> (Optional) See L =item C<< 'node' => $node >> (Required for class method, Not Applicable for instance method) Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : node =item C<< 'speed' => $string >> Applicable for CMode CLI. =item C<< 'state' => $string >> Applicable for CMode CLI. =item C<< 'method-timeout' => $time_in_seconds >> (Optional) The default NATE timeout is 60 seconds. If the command might take more time to complete, this option can be used to specify a larger timeout value. The value should be provided in seconds. =item C<< 'adapter' => $string >> Applicable for CMode CLI/ZAPI Maps to: CM ZAPI : fcp-adapter =item C<< 'extended_query' => $string >> (Optional) Applicable for CMode CLI. =item C<< '*' >> This method takes all other options supported by "network fcp adapter modify" command in ONTAP. Applicable for CMode CLI. =back =back =over =item Exceptions =over =item C In general, Component methods propagate the exceptions thrown from underlying API layer and the details of those exceptions are described in the L of user guide. =back =back =cut sub modify { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_frontend_log_debug_opts(@args); my %opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => {_optional_scalars(qw( speed state adapter node )),}, cli_cmd => 'network fcp adapter modify', ); $pkg_or_obj->call_on_apiset( %opts, choices => [ { method => '_modify_cmode_cli', interface => 'CLI', set => 'CMode', }, { method => '_modify_cmode_zapi', interface => 'ZAPI', set => 'CMode', }, ], frontend => 'NACL::C::NetworkFcpAdapter::modify', ); $Log->exit() if $may_exit; } ## end sub modify sub _modify_cmode_zapi { $Log->enter() if $may_enter; my $pkg_or_obj = shift; my %opts = $pkg_or_obj->_validate_backend_opts(@_); delete $opts{command_interface}; my $apiset = delete $opts{apiset}; my %cmode_args; $pkg_or_obj->_hash_copy( source => \%opts, copy => [qw(node)], map => {'adapter' => 'fcp-adapter'}, target => \%cmode_args, ); if (defined $opts{'state'} && $opts{'state'} eq 'up') { $apiset->fcp_adapter_config_up(%cmode_args); } elsif (defined $opts{'state'} && $opts{'state'} eq 'down') { $apiset->fcp_adapter_config_down(%cmode_args); } elsif (defined $opts{'state'}) { $Log->exit() if $may_exit; NATE::Exceptions::Argument->throw( 'Invalid option passed to modify method'); } if (defined $opts{'speed'}) { $cmode_args{'speed'} = $opts{'speed'}; $apiset->fcp_adapter_set_speed(%cmode_args); } $Log->exit() if $may_exit; } ## end sub _modify_cmode_zapi sub _modify_cmode_cli { $Log->enter() if $may_enter; my ($pkg_or_obj, @args) = @_; $pkg_or_obj->_base_backend_cmode_cli(@args, api => 'network_fcp_adapter_modify'); $Log->exit() if $may_exit; } ## end sub _modify_cmode_cli __PACKAGE__->_load_event_class(); sub _primary_keys_validate_spec { return ( 'adapter' => {type => SCALAR}, 'node' => {type => SCALAR}, ); } ## end sub _primary_keys_validate_spec 1;