# # Copyright (c) 2001-2014 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VserverNfsKerberosInterface STask Module ## @author dl-nacl-dev@netapp.com ## @status shared ## @pod here package NACL::STask::VserverNfsKerberosInterface; use strict; use warnings; use base qw(NACL::C::VserverNfsKerberosInterface NACL::STask::STask); use NATE::Log qw(log_global); my $Log = log_global(); my $may_enter = $Log->may_enter(); my $may_exit = $Log->may_exit(); use Params::Validate qw(:all); use NACL::ComponentUtils qw(Dumper); use Time::Local; use NATE::BaseException qw(:try); =head1 NAME NACL::STask::VserverNfsKerberosInterface =head1 DESCRIPTION C provides a number of well-defined but potentially complex or multi-step methods related to VserverNfsKerberosInterface's in ONTAP. It builds on top of, and is a derived class of C, and so it also provides methods that are more in the scope of individual VserverNfsKerberosInterface-related commands. See C for details. This also means that a C object may generally be used in place of a component object. =head1 ATTRIBUTES =head2 command_interface (Required) As C. A component object that represents the host to which to send commands. =head1 METHODS =head2 enable my $VserverNfsKerberosInterface = NACL::STask::VserverNfsKerberosInterface->enable( command_interface => $command_interface, lif => $lif_name, vserver => $vserver_name, if_exists => $action, # default 'die' %other_options ); (Class method) Enable a VserverNfsKerberosInterface. This method provides additional services beyond what's inherent to the product's VserverNfsKerberosInterface enable commands, as controlled and described by the new C option. =over =item Options =over =item C<< nacltask_if_enabled=>$action >> (Optional) What to do if the VserverNfsKerberosInterface to be enabled is already enabled. If $action is "die" (the default), then fail with an exception (in the same way that the VserverNfsKerberosInterface component would have: by trying the VserverNfsKerberosInterface enable and letting the product complain about the VserverNfsKerberosInterface already existing). If action is "pass", then do nothing (return a task object referring to the existing VserverNfsKerberosInterface). =item C<< _was_enabled => \$scalar >> (Optional) When this option is provided a reference to a scalar variable, the variable gets filled in with a boolean value describing whether the volume was found (value will be 0; this scenario is possible when nacltask_if_exists => "pass") or whether the VserverNfsKerberosInterface was enabled (value will be 1). This is necessary to determine whether the VserverNfsKerberosInterface needs to be cleaned up later. my $was_enabled; my $VserverNfsKerberosInterface_obj = NACL::STask::VserverNfsKerberosInterface->enable( nacltask_if_enabled => 'pass', _was_enabled => \$was_created, %other_opts ); # Operate on $VserverNfsKerberosInterface_obj here # ... # Now determine whether to clean up the kerberos interface, since we're not sure # whether we reused an existing VserverNfsKerberosInterface or enabled a new one if ($was_enabled) { # kerberos interface was enabled. Clean it up. $VserverNfsKerberosInterface_obj->disable(); } =item C<< lif=>$lif_name >> (Required) Name of the lif. =item command_interface, apiset_must, apiset_should, lif, etc. All of the other various options to C<< NACL::C::VserverNfsKerberosInterface->enable|lib-NACL-C-VserverNfsKerberosInterface-pm/enable >> =back =back =over =item Arguments defaulted/auto-determined =over =item C<< nacltask_to_cleanup => 0|1 >> (Optional, defaults to 0(no to cleanup)) Flag indicating if this operation is to be cleaned up or not. =item C<< nacltask_cleanup_manager >> Cleanup manager to use for registering. Default : Will use the default cleanup manager. =back =over =item Exceptions =over =item C This type of exception is thrown when an attempt is made to enable a VserverNfsKerberosInterface that is already enabled. =back =cut sub enable { $Log->enter() if $may_enter; my $pkg = shift; my %opts = $pkg->_common_validate_with( params => \@_, additional_spec => { nacltask_if_enabled => $pkg->_if_action_completed_already_validate_spec, _was_enabled => { type => SCALARREF, optional => 1 }, $pkg->_cleanup_validate_spec(), }, allow_extra => 1, ); # move the cleanup related options to separate hash my (%opts_for_cleanup, %opts_for_register, $nacltask_to_cleanup); $pkg->_move_common_cleanup_opts( source => \%opts, target => \%opts_for_cleanup, ); my $if_enabled = delete $opts{nacltask_if_enabled}; my $was_enabled = delete $opts{_was_enabled}; $$was_enabled = 0; my $self; try { $self = $pkg->SUPER::enable(%opts); $$was_enabled = 1; } ## end try catch NACL::C::Exceptions::VserverNfsKerberosInterface::AlreadyEnabled with { my $e = shift; # Check if the command failed because the VserverNfsKerberosInterface # was already enabled if ( $if_enabled !~ /pass/i ) { $Log->exit() if $may_exit; $e->throw(); } }; # Register this resource with the Cleanup Manager for cleanup $pkg->_copy_common_opts_for_cleanup( 'source' => {%opts, %opts_for_cleanup}, 'target' => \%opts_for_register, 'nacltask_to_cleanup' => \$nacltask_to_cleanup, 'to_cleanup' => 'disable' ); $pkg->_register_for_cleanup(%opts_for_register) if ( $nacltask_to_cleanup && $$was_enabled ); $Log->exit() if $may_exit; return $self; } ## end sub enable =head2 disable $VserverNfsKerberosInterface->disable(); (or) NACL::STask::VserverNfsKerberosInterface->disable( command_interface => $command_interface, lif => $lif_name, vserver => $vserver_name, nacltask_if_disabled => $if_disabled, %other_options ); (Class or Instance method) Disables the VserverNfsKerberosInterface Uses a CMode CLI/ZAPI. =over =item Options =over =item C<< command_interface => $ci >> (Required for class method, Not Applicable for instance method) A component object that represents the host which to send commands. See NACL::C::Component::command_interface =item C<< vserver => $vserver_name >> (Required for class method, Not Applicable for instance method) The name of the vserver. =item C<< lif=>$lif_name >> (Required) Name of the lif. =item C<< _was_disabled => \$scalar >> (Optional) When this option is provided a reference to a scalar variable, the variable gets filled in with a boolean value describing whether the VserverNfsKerberosInterface was already disabled (value will be 0; this scenario is possible when nacltask_if_disabled => "pass") or whether the VserverNfsKerberosInterface was disabled (value will be 1). =item C<< nacltask_if_disabled=>die|pass >> (Optional) If "die", exception is thrown when VserverNfsKerberosInterface to be disabled is already disabled If "pass", exits quietly when VserverNfsKerberosInterface to be disabled is already disabled command_interface, apiset_must, apiset_should, etc. All of the other various options to NACL::C::VserverNfsKerberosInterface->disable. =back =over =item Exceptions =over =item C This type of exception is thrown when an attempt is made to disable VserverNfsKerberosInterface that is already disabled. =back =cut sub disable { $Log->enter() if $may_enter; my ( $pkg_or_obj, @args ) = @_; my %orig_opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => { nacltask_if_disabled => $pkg_or_obj->_if_action_completed_already_validate_spec, _was_disabled => { type => SCALARREF, optional => 1 }, }, allow_extra => 1, ); my $if_disabled = delete $orig_opts{nacltask_if_disabled}; my $was_disabled = delete $orig_opts{_was_disabled}; $$was_disabled = 0; try { $pkg_or_obj->SUPER::disable(%orig_opts); $$was_disabled = 1; } catch NACL::C::Exceptions::VserverNfsKerberosInterface::AlreadyDisabled with { my $e = shift; # Check if the command failed because the VserverNfsKerberosInterface # was already disabled if ( $if_disabled !~ /pass/i ) { $Log->exit() if $may_exit; $e->throw(); } }; $Log->exit() if $may_exit; } ## end sub disable =head2 modify $VserverNfsKerberosInterface->modify(); (or) NACL::STask::VserverNfsKerberosInterface->modify( command_interface => $command_interface, lif => $lif_name, vserver => $vserver_name, nacltask_if_disabled => $if_disabled, %other_options ); (Class or Instance method) Disables the VserverNfsKerberosInterface Uses a CMode CLI/ZAPI. =over =item Options =over =item C<< command_interface => $ci >> (Required for class method, Not Applicable for instance method) A component object that represents the host which to send commands. See NACL::C::Component::command_interface =item C<< vserver => $vserver_name >> (Required for class method, Not Applicable for instance method) The name of the vserver. =item C<< lif=>$lif_name >> (Required) Name of the lif. =item C<< _was_modified => \$scalar >> (Optional) When this option is provided a reference to a scalar variable, the variable gets filled in with a boolean value describing whether the VserverNfsKerberosInterface was already modified (value will be 0; this scenario is possible when nacltask_if_modified => "pass") or whether the VserverNfsKerberosInterface was modified (value will be 1). =item C<< nacltask_if_modified=>die|pass >> (Optional) If "die", exception is thrown when VserverNfsKerberosInterface to be modified is already modified If "pass", exits quietly when VserverNfsKerberosInterface to be modified is already modified command_interface, apiset_must, apiset_should, etc. All of the other various options to NACL::C::VserverNfsKerberosInterface->modify. =back =over =item Exceptions =over =item C This type of exception is thrown when an attempt is made to disable VserverNfsKerberosInterface that is already disabled. =item C This type of exception is thrown when an attempt is made to enable a VserverNfsKerberosInterface that is already enabled. =back =cut sub modify { $Log->enter() if $may_enter; my ( $pkg_or_obj, @args ) = @_; my %orig_opts = $pkg_or_obj->_common_validate_with( params => \@args, additional_spec => { nacltask_if_modified => $pkg_or_obj->_if_action_completed_already_validate_spec, _was_modified => { type => SCALARREF, optional => 1 }, }, allow_extra => 1, ); my $if_modified = delete $orig_opts{nacltask_if_modified}; my $was_modified = delete $orig_opts{_was_modified}; $$was_modified = 0; try { $pkg_or_obj->SUPER::modify(%orig_opts); $$was_modified = 1; } catch NACL::C::Exceptions::VserverNfsKerberosInterface::AlreadyDisabled with { my $e = shift; # Check if the command failed because the VserverNfsKerberosInterface # was already disabled if ( $if_modified !~ /pass/i ) { $Log->exit() if $may_exit; $e->throw(); } } catch NACL::C::Exceptions::VserverNfsKerberosInterface::AlreadyEnabled with { my $e = shift; # Check if the command failed because the VserverNfsKerberosInterface # was already enabled if ( $if_modified !~ /pass/i ) { $Log->exit() if $may_exit; $e->throw(); } }; $Log->exit() if $may_exit; } ## end sub modify 1;