# # Copyright (c) 2011-2013 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary VserverServicesNisDomain Task Module ## @author rahula@netapp.com, dl-nacl-dev ## @status shared ## @pod here package NACL::STask::VserverServicesNisDomain; use strict; use warnings; use base qw(NACL::C::VserverServicesNisDomain 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 NACL::STask::_VserverServices qw(:all); use Params::Validate qw(BOOLEAN); =head1 NAME NACL::STask::VserverServicesNisDomain =head1 DESCRIPTION C provide methods to create, purge vserver services nis in ONTAP. It is created on top of C component Since it is derived class of C, we can use all the methods of C from the object of this task. =head1 CLEANUP METHODS Cleanup can be registered for the following methods, Cleanup methods are, VserverServicesNisDomain Method Cleanup Method ----------------------------------------------- create purge =head1 ATTRIBUTES =head2 command_interface (Required) A component object that represents the node to which to send commands See L. =head2 vserver (Required) The name of the Vserver to be used. =head1 METHODS =head2 create my $nis_obj = NACL::STask::VserverServicesNisDomain->create( 'command_interface' => $ci, 'vserver' => $vserver, 'domain' => $Domain, 'servers' => \@Servers, 'active' => $Active, 'nacltask_if_exists' => $action # default die 'nacltask_to_cleanup' => 1, #default 0 'nacltask_cleanup_manager' => $CleanupObj, %other_options, ); (Class Method) This method is used to configure NIS on the particular vserver. If NIS service already exists, it will perform the action based on "nacltask_if_exists" parameter. Default behavior would be "die". =over =item Options =over =item C<< command_interface => $command_interface >> (Required) See L =item C<< 'vserver' => $vserver >> (Required) Name of the vserver to be used. =item C<< "domain" => $domain >> (Required) The NIS domain name which needs to be configured for the vserver. =item C<< active=>$string >> (Optional) Active Domain. It will take either true or false as value. Default value is true. =item C<< servers => [ $server1, $server2, ... ] >> (Required ArrayRef) This specifies the IP address or addresses of one or more NIS servers for the NIS domain configuration. You can specify multiple IP addresses by using a comma-separated list. =item C<< "nacltask_if_exists => $action" >> (Optional) What to do if the NIS to be configured already exists. If $action is "die", then fail with NACL::C::Exceptions::VserverServicesNisDomain::AlreadyExists exception. If $action is "purge",then purge the NIS configuration(see the "purge" method, below) before creating a new one. If $action is "reuse", It will return the object of existing NIS configuration for the vserver. =item C<< "nacltask_verify => $action" >> (Optional) The user of this library can specify to verify whether the NIS is configured or not. If the action is 0, which is default, verification is not done. If the user sets the action to 1, it will verify it using the component state of this library. =item C<< "_was_created => \$scalar" >> (Optional) When this option is provided with a reference to a scalar variable, the variable gets filled in with a boolean value describing whether the NIS was available (value will be 0; this scenario is possible when if_exists => "reuse") or whether the NIS was created (value will be 1). This is necessary to determine whether the NIS configuration needs to be cleaned up later. my $was_created; my $nis_obj = NACL::STask::VserverServicesNisDomain->create( nacltask_if_exists => 'reuse', _was_created => \$was_created, %other_opts ); # Operate on $nis_obj here # Now determine whether to clean up the nis, since we're not sure # whether we reused an existing nis or created a new one if ($was_created) { # New NIS configuration. Clean it up. $nis_obj->purge(); } =item C<< nacltask_verify_yp_conf_file => $boolean >> (Optional) This parameter is a boolean option. If the value is 1, the NIS configuration which is created is checked in the yp.conf file. The path of the file is /clus/.vserver_/.vsadmin/config/etc . If the value is 1, the NIS configuration is checked in that file. Defaults to 0. (This option is deprecated) =item C< $boolean >> This option verifies whether the file-version and rdb-version are in sync within the same node and across all nodes in a cluster. It defaults to 0 , verification will not be done. If set to 1, it will verify. =item C< $scalar >> The user of this library can verify the file-version command based on number of retries. This option will be set to 6(default),means a user can do 6 retries to verify file-verison and rdb-version are in sync. =item C< $scalar >> The user of this library can verify the file-version command based on an interval of 10seconds. This option will be set to 10(default),means a user can execute the command with an interval of 10seconds in 6 retries.. =item C<< nacltask_to_cleanup => 0|1 >> (Optional, default to 0(no to cleanup) Flag indicating if this operation needs to be registered for clean up or not. =item C<< nacltask_cleanup_manager >> Cleanup manager to be used for registering. Default : Will use the default cleanup manager. =item C The options accepted for MCC configuration replication verification is documented at L. =back command_interface, apiset_must, apiset_should, mode, etc. All of the other various options, See L<< NACL::C::VserverServicesNisDomain::create|lib-NACL-C-VserverServicesNisDomain-pm/create >> =back =over =item Exceptions =over =item C This type of exception is thrown when an attempt is made to configure NIS on a given vserver when it already exists. =item C This type of exception is thrown when verification fails for the NIS configured on a given vserver. =back =back =cut sub create { $Log->enter() if $may_enter; my $pkg = shift; my $self = $pkg->_create_helper(@_); $Log->exit() if $may_exit; return $self; } ## end sub create =head2 purge my $was_deleted; $nis_obj->purge(); (or) NACL::STask::VserverServicesNisDomain->purge( 'command_interface' => $ci, 'vserver' => $vserver_name, 'domain' => $Domain, 'nacltask_verify' => 1, '_was_deleted' => \$was_deleted ); (Class or instance method) This method is used to remove NIS configured for a particular vserver. =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 L. =item C<< 'vserver' => $vserver >> (Required for class method, Not Applicable for instance method) Name of the vserver to be used. =item C<< nacltask_verify => $nacltask_verify_boolean >> (Optional) If '0' (default), verification will not be performed. If '1', verification will be performed to ensure that the deletion did happen successfully. =item C<< nacltask_if_purged => $nacltask_if_purged >> (Optional) Default value is 'fail'. If 'pass', it will pass if the NIS domain configuration is already deleted. If 'fail', NACL::C::Exceptions::VserverServicesNisDomain::DoesNotExist type of exception is raised. =item C<< nacltask_verify_yp_conf_file => $boolean >> (Optional) This parameter is a boolean option. If the value is 1, the NIS configuration which is deleted is checked in the yp.conf file. The path of the file is /clus/.vserver_/.vsadmin/config/etc . If the value is 1, the NIS configuration is checked in that file. Defaults to 0. (This option is deprecated) =item C<< _was_deleted => \$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 did not exist (value will be 0; this scenario is possible when nacltask_if_purged => "pass") or whether the NIS was deleted (value will be 1). =item C The options accepted for MCC configuration replication verification is documented at L. =back All of the other various options, See L<< NACL::C::VserverServicesNisDomain::delete|lib-NACL-C-VserverServicesNisDomain-pm/delete >> =back =over =item Exceptions =over =item C This type of exception is thrown when an attempt is made to delete NIS configuration on a given vserver whch does not exists. =item C This type of exception is thrown when verification fails for the deleted NIS configuration. =back =back =cut sub purge { $Log->enter() if $may_enter; my $pkg_or_obj = shift; $pkg_or_obj->_purge_helper(@_); $Log->exit() if $may_exit; } ## end sub purge 1;