# # Copyright (c) 2012 NetApp, Inc., All Rights Reserved # Any use, modification, or distribution is prohibited # without prior written consent from NetApp, Inc. # ## @summary Switch Task Module for Switch ## @author rawat@netapp.com ## @status shared ## @pod here package NACL::STask::Switch; use strict; use warnings; use base qw(NACL::C::Switch); use Tharn qw( sleep); 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(validate_with SCALAR BOOLEAN); use NACL::APISet::Exceptions::InvalidParamValueException qw(:try); use NACL::ComponentUtils qw(Dumper); =head1 NAME NACL::STask::Switch =head1 DESCRIPTION C provide methods to reboot switch. 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 ATTRIBUTES =head2 command_interface (Required) A component object that represents the host to which to send commands. See L. =head1 METHODS =head2 reboot $switch->reboot( command_interface => $command_interface, nacltask_wait => 1, ); (Instance Method) This method will reboot the switch. =over =item Options =back =over =item C<< nacltask_wait => boolean >> (Optional) If set to 1, it will wait for switch to come back up =back =cut sub reboot { $Log->enter(); my ($pkg, @opts) = @_; my %opts = $pkg->_common_validate_with( params => \@opts, additional_spec => { nacltask_wait => { type => SCALAR, default => 1 }, }, allow_extra => 1, ); my $command_interface = delete $opts{command_interface}; $Log->debug( sub { "Options to reboot:\n" . Dumper(\%opts); } ); $pkg->SUPER::reboot(command_interface => $command_interface); if ($opts{nacltask_wait}) { # Should wait for some time before refreshing the connection # because switch will be responsive for couple of seconds # before it starts rebooting $Log->comment("Sleeping for 10 secs before refreshing " . "the command interface"); Tharn::sleep(10); # Will try 2 times and wait for 60 secs each time $command_interface->refresh_command_interface(max_reconnect => 2); } $Log->exit(); } #end of sub reboot 1;