#!/usr/software/bin/perl # $Id: //depot/prod/test/main/storage/hdd/NADQ_SEA/CMODE/FORCE_CONVERT_SETUP_INSTALL_IMAGE.thpl#8 $ # Copyright (c) 2005 Network Appliance, Inc. # All rights reserved # ## @summary Mode ## Setup conversion 7Mode to CMode and vice versa ## ## @description ## Set-up conversion with or without installation of kernel image ## ## @Test Mode ## Maintenance mode/File system mode /LOADER ## ## ## ## @usage ## The test has run independently as part of STEST. ## ## @dependencies ## for conversion both the Filer-configuration files are necessary(_BR and _CMODE) ## ## @status Automated # @auther Arjun.Lavu@netapp.com ## @burt 758407 ## @change YY/MM/DD from auther: Description of the change ## ############################################################################# # Compiler directives. use strict; use warnings; # MODULES imports use Storage::Common_Lib; #User defined functions #sub _array_diff(\@\@); # Global parameters use vars qw( $FILER $FILERA $FILERB $FILER_CONN $TEST_CONFIG $TEST_SETUP $MODE $FILER_PROMPT $LOGDIR $EOE $TEST_WAIT_TIME $BOOT_MODE $BOOT_TYPE $SSD $EMAIL $MAIL_TO $MAIL_FROM $ARMADILLO $ERT_TEST_ID $FILER_TYPE $Primary_Node $CONVERT_TO $IMAGE ); my $params = NATE::ParamSet->new(global => 1); $FILER = $params->get( 'FILER', default =>'Filer' ); $FILERA = $params->get( "FILERA", default =>'' ); $FILERB = $params->get( "FILERB", default =>'' ); $FILER_CONN = $params->get( "FILER_CONN", default =>'#console' ); $MODE = $params->get( "MODE", default =>'maint' ); $FILER_PROMPT = $params->get( "FILER_PROMPT", default =>'\*>' ); $LOGDIR = $params->get( 'LOGDIR', default =>'' ); $TEST_SETUP = $params->get( 'TEST_SETUP', default =>'FC' ); $TEST_WAIT_TIME = $params->get( 'TEST_WAIT_TIME', default =>'3' ); $ARMADILLO = $params->get( "ARMADILLO", default =>'2' ); $ERT_TEST_ID = $params->get( "ERT_TEST_ID", default =>'' ); $EOE = $params->get( 'EOE', default =>'default' ); $BOOT_MODE = $params->get( 'BOOT_MODE', default =>'1' ); $BOOT_TYPE = $params->get( 'BOOT_TYPE', default =>'A' ); $SSD = $params->get( 'SSD', default =>'no' ); $EMAIL = $params->get( 'EMAIL', default =>'y' ); $MAIL_TO = $params->get( 'MAIL_TO', default => 'Email to' ); $MAIL_FROM = $params->get( 'MAIL_FROM', default => 'Email from' ); $FILER_TYPE = $params->get( 'FILER_TYPE', default => 'DataONTAP version'); $TEST_CONFIG = $params->get( 'TEST_CONFIG', default => 'D'); $Primary_Node = $params->get( 'Primary_Node', default => 'N' ); $CONVERT_TO = $params->get( 'CONVERT_TO', default => 'N' ); $IMAGE = $params->get( 'IMAGE', default => 'N'); #Cmode and common variables my $Test; my $Mode; my $Filer_names; my %FILER_STATE; my @FILER_ARR; my @Nodes; my @API_ARRAY; my @Nodes_all; my %nodes_filer; my %FILER_API; my %Fil_disk; my %FILER_MODE; my %FILER_INSTALL_IMAGE; ##for future use my %FILER_CONVERT; my ($email_subject,$email_body); my $test_status =0; my $TC_name = "FORCE_CONVERT_SETUP_INSTALL_IMAGE"; ######################################### # Testcase available for execution ######################################### my @Testcases = ( FORCE_CONVERT_SETUP_INSTALL_IMAGE => "FORCE_CONVERT_SETUP_INSTALL_IMAGE" ); &main(); sub main { # Debug break point $DB::single = 2; # Create Test Case Driver object $Test = new TCD( -testcases => [@Testcases] ); if ( $Test->error ) { $Test->nlog( $Test->errmsg ); $test_status = 1; $email_subject = "$TC_name : Test FAILED: FAIL"; $email_body = "Failed to instantiate Test object.\nLog Location : $LOGDIR\n"; send_message( mail_subject => $email_subject, mail_body => $email_body, MAIL_FROM => $MAIL_FROM, MAIL_TO => $MAIL_TO, EOE => $EOE, EMAIL => $EMAIL ); return $TCD::FAIL; } # Performs method callbacks $Test->run_test(); if ( $Test->error ) { $Test->nlog( $Test->errmsg ); return $TCD::FAIL; } exit(0); } ## end sub main ########## INIT ################################################### # This init subroutine will initialise the filer. #################################################################### sub init() { $Test->description("########## Finding Nodes ######### Initialising the Filer"); $Filer_names = $Test->get_param("FILER"); logcomment("Filers present are $Filer_names"); my @Nodes_temp = NACL::C::Node->find(); foreach my $Node (@Nodes_temp) { my $FILER_C = $Node->name(); $nodes_filer{$FILER_C} = [$Node]; } @Nodes = map{@{$_}} values(%nodes_filer); @Nodes_all = @Nodes; logcomment("Test $TC_name starting: ". scalar(localtime())); if((scalar @Nodes < 2)&&($CONVERT_TO eq 'CMode')){ logresult('FATAL',"To convert to CMODE atleast two Nodes are required"); } =head my $FILER = $_->name(); $Mode = $_->mode(); logcomment("Filer : $FILER - Filer Mode found from the configuration file is $Mode"); if(($CONVERT_TO=~/7Mode/i)&&($IMAGE =~/fullsteam/ig)){ logcomment("Kernel Image given by the user is : $IMAGE"); logcomment("$FILER : User selected to convert filer to 7Mode"); logresult('FATAL',"Cannot install fullsteam kernel on 7Mode filer"); } logcomment("Filer - $FILER : Checking the Mode of filer before proceeding"); my $Transit_obj = NACL::Transit->new( name => $FILER); try{ $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); ##capturing the filer state and booting to the same state if necessary in the clean-up }catch NACL::Transit::Exceptions::Timeout with{ my $Host = host($FILER); my $filer_con = connect("$FILER#console"); $filer_con->timeout("1200"); my ($match,$after,$before,$prompt)=say($filer_con, '\013',"-prompt",".*::>.*", -timeout, 60,-ok ); if($prompt=~/\:\:\>/){ say($filer_con, 'run local halt -f -t 0', -timeout, 600,-ok ); }else{ say($filer_con, 'exit', -timeout, 600,-ok ); } try{ $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); }catch NACL::Transit::Exceptions::Timeout with{ my (undef,undef,undef,$prompt)=say($filer_con, '\013',"-prompt",".*::>.*", -timeout, 60,-ok ); if($prompt=~/\:\:\>/){ say($filer_con, 'run local halt -f -t 0', -timeout, 600,-ok ); }else{ say($filer_con, 'exit', -timeout, 600,-ok ); } $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); } }; logcomment("Filer : $FILER : Current state of the filer is $FILER_STATE{$FILER}"); ##If configuration file is in 7Mode and filer state is in CMode CLI the halt -f -t 0 command will not work so executing like below if(($Mode =~/7Mode/i)&&($FILER_STATE{$FILER}=~/^CLI$/)){ logcomment("Filer - $FILER : halting the filer"); my $Host = host($FILER); my $filer_con = connect("$FILER#console"); $filer_con->timeout("1200"); my ($match,$after,$before,$prompt)=say($filer_con, '\013',"-prompt",".*::>.*", -timeout, 60,-ok ); if($prompt=~/\:\:\>/){ say($filer_con, 'run local halt -f -t 0', -timeout, 600,-ok ); } $Transit_obj->change_state( to => "FIRMWARE" ); ##if filer is not CMODE this will work }elsif($FILER_STATE{$FILER} =~/USERNAME/ig){ ##if filer is in USERNAME mode that means filer is in CMODE, so for safety reading my $Home = $ENV{HOME}; ## password from the Cmode con-fig file my $FILER_C = "$FILER"."_C"; my $passwd = 'empty'; my $username = 'admin'; $/=undef; open(FH,"$Home/NDATE/FILER_INFO/$FILER_C")||die "no file found under $Home/NDATE/FILER_INFO/$FILER_C"; my $data = ; close FH; $/= "\n"; ($passwd) = $data=~/default_password\s*=\s*(\S+)/ig; chomp($passwd); logcomment("password is $passwd"); my $filer_con = connect("$FILER#console"); my(undef, undef, undef, $prompt1) = say($filer_con, "admin", -prompt, ["login","Password"], -timeout, 120, -ok); if($prompt1=~/login/){ my(undef, undef, undef, $prompt2)=say($filer_con, "admin",-timeout, 60, -ok); if($prompt2=~/Password/i){ say($filer_con, "$passwd",-timeout, 60, -ok); } } if($prompt1=~/Password/i){ say($filer_con, "$passwd",-timeout, 60, -ok); } my(undef, $match, undef, $prompt3)=say($filer_con, "\013", -timeout, 60, -ok); if(($match=~/::>/)||( $prompt3=~/::>/)){ say($filer_con, 'run local halt -f -t 0', -timeout, 600,-ok ); } $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); }elsif($FILER_STATE{$FILER} !~/FIRMWARE/ig){ logcomment("Filer : $FILER - changing state to FIRMWARE"); $Transit_obj->change_state( to => "FIRMWARE" ); }else{ logcomment("Filer : $FILER : Filer is already in FIRMWARE state"); } $FILER_STATE{$FILER} = 'CLI' if($FILER_STATE{$FILER}=~/Password|USERNAME|DBLADECLI/ig); my $get = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); if($get !~/FIRMWARE/){ logresult('FATAL',"Couldn't change the state of filer to LOADER"); } } =cut foreach(@Nodes){ my $FILER = $_->name(); $Mode = $_->mode(); logcomment("Filer : $FILER - Filer Mode found from the configuration file is $Mode"); if(($CONVERT_TO=~/7Mode/i)&&($IMAGE =~/fullsteam/ig)){ logcomment("Kernel Image given by the user is : $IMAGE"); logcomment("$FILER : User selected to convert filer to 7Mode"); logresult('FATAL',"Cannot install fullsteam kernel on 7Mode filer"); } logcomment("Filer - $FILER : Checking the Mode of filer before proceeding"); my $Transit_obj = NACL::Transit->new( name => $FILER); try{ $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); ##capturing the filer state and booting to the same state if necessary in the clean-up }catch NACL::Transit::Exceptions::Timeout with{ my $Host = host($FILER); my $prompt_array = $Host->prompt_fw(); my $prompts = join("|",@$prompt_array); my $ignore_strings = ["MADIMM\\d+->","DIMM\\d+->","^T>"]; my $prompt_fw = "($prompts)"; logcomment("This is the prompt regex: $prompt_fw"); my $Server = new Server(no_cli=>1); $Server->set_execution_server(-Server => $FILER); #set the execution server to the current node my @filer_working = $Server->servers(); logcomment("Number of filers working are @filer_working"); try{ $Server->console(cmd => " ", additional_prompts_timeout => 600, ignore => $ignore_strings, additional_prompts => { ".*::>.*" => "FATAL_PROMPT", "$prompt_fw" => "FINAL_PROMPT", } ); }catch NATE::BaseException with{ $Server->console(cmd => "run local halt -f -t 0", additional_prompts_timeout => 600, ignore => $ignore_strings, additional_prompts => { "$prompt_fw" => "FINAL_PROMPT", } ); }; $FILER_STATE{$FILER} = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); }; #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ my $prompt_fw ; my $ignore_strings = ["MADIMM\\d+->","DIMM\\d+->","^T>"]; my $Host = host($FILER); my $prompt_array = $Host->prompt_fw(); my $prompts = join("|",@$prompt_array); $prompt_fw = "($prompts)"; logcomment("This is the prompt regex: $prompt_fw"); my $Server = new Server(no_cli=>1); $Server->set_execution_server(-Server => $FILER); #set the execution server to the current node my @filer_working = $Server->servers(); logcomment("Number of filers working are @filer_working"); #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ logcomment("Filer : $FILER : Current state of the filer is $FILER_STATE{$FILER}"); ##If configuration file is in 7Mode and filer state is in CMode CLI the halt -f -t 0 command will not work so executing like below if(($Mode =~/7Mode/i)&&($FILER_STATE{$FILER}=~/^CLI$/)){ logcomment("Filer - $FILER : halting the filer"); $Server->console(cmd => "run local halt -f -t 0", additional_prompts_timeout => 600, ignore => $ignore_strings, additional_prompts => { ".*not found.*" => "FINAL_PROMPT", "$prompt_fw" => "FINAL_PROMPT", } ); $Transit_obj->change_state( to => "FIRMWARE" ); ##if filer is not CMODE this will work }elsif($FILER_STATE{$FILER} =~/USERNAME/ig){ ##if filer is in USERNAME mode that means filer is in CMODE, so for safety reading my $Home = $ENV{HOME}; ## password from the Cmode con-fig file my $FILER_C = "$FILER"."_C"; my $passwd = 'empty'; my $username = 'admin'; $/=undef; open(FH,"$Home/NDATE/FILER_INFO/$FILER_C")||die "no file found under $Home/NDATE/FILER_INFO/$FILER_C"; my $data = ; close FH; $/= "\n"; ($passwd) = $data=~/default_password\s*=\s*(\S+)/ig; logcomment("password is $passwd"); try{ $Server->console(cmd => "\n", additional_prompts_timeout => 600, ignore => $ignore_strings, additional_prompts => { ".*login.*" => "admin", ".*Password.*" => $passwd, ".*::>.*" => "FINAL_PROMPT", ".*Login incorrect.*" => 'FATAL_PROMPT', "$prompt_fw" => "FINAL_PROMPT", } ); }catch NATE::BaseException with{ logcomment("FILER - $FILER : WARNING : Incorrect login, Please check the configuration file "); }; logcomment("Filer : $FILER : Filer is not in LOADER prompt, so changing state to LOADER"); logcomment("Filer - $FILER : halting the filer"); $Server->console(cmd => "run local halt -f -t 0", additional_prompts_timeout => 600, ignore => $ignore_strings, additional_prompts => { ".*not found.*" => "FINAL_PROMPT", "$prompt_fw" => "FINAL_PROMPT", } ); }elsif($FILER_STATE{$FILER} !~/FIRMWARE/ig){ logcomment("Filer : $FILER - changing state to FIRMWARE"); $Transit_obj->change_state( to => "FIRMWARE" ); }else{ logcomment("Filer : $FILER : Filer is already in FIRMWARE state") } $FILER_STATE{$FILER} = 'CLI' if($FILER_STATE{$FILER}=~/Password|USERNAME|DBLADECLI/ig); my $get = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); if($get !~/FIRMWARE/){ logresult('FATAL',"Couldn't change the state of filer to LOADER"); } my $data = $Server->console(cmd => "printenv", additional_prompts_timeout => 60, ignore => $ignore_strings, additional_prompts => { "$prompt_fw" => "FINAL_PROMPT", } ); my $actual_state; ($actual_state) = $data=~/bootarg.init.boot_clustered\s+(\S+)/; if($actual_state =~/true/gi){ logcomment("Filer - $FILER is in CMode"); }elsif($actual_state =~/false/gi){ logcomment("Filer - $FILER is in 7Mode"); if(($CONVERT_TO=~/7Mode/i)&&($IMAGE =~/fullsteam/ig)){ logcomment("Kernel Image given by the user is :: $IMAGE"); logcomment("$FILER : Mode of the filer found from bootarg.init.boot_clustered is 7Mode, so Cannot install fullsteam kernel on 7Mode filer"); logresult('FATAL',"Cannot install fullsteam kernel on 7Mode filer"); } }else{ logcomment("Filer - $FILER : Variable bootarg.init.boot_clustered is not not set either true or false"); logcomment("Filer - $FILER : Converting the setup based on the user input i.e $CONVERT_TO"); } } return $TCD::PASS; } ## end sub init() ##################################################################### # setup ##################################################################### sub setup() { $Test->description("Inside Setup Setting the variables in LOADER prompt if required"); _set_environment(); ##Setting environment variables based on the mode of the filer my @subtest; foreach(@Nodes){ my $FILER = $_->name(); logcomment("Filer : $FILER : executing wipe-config on the filer"); push(@subtest, subtest(\&clean_config, -runid, "clean_config_" . "$FILER", -bg, "--", Node => $_, ) ); } logcomment("Subtest @subtest"); Subtest::wait_finish( subtest => [@subtest] ); return $TCD::PASS; } ##################################################################### # Calling sub FORCE_CONVERT_SETUP_INSTALL_IMAGE ##################################################################### sub FORCE_CONVERT_SETUP_INSTALL_IMAGE{ #$Test->description(" Installing Image if required"); if($IMAGE ne 'N'){ $Test->description("Installing Image on the filers"); my ( $fail_cnt, $fatal_cnt )= 0; { my @subtests; foreach(@Nodes){ my $FILER = $_->name(); logcomment("Filer : $FILER installing new Image on the filer"); push(@subtests, subtest(\&compact_flash, -runid, "Install_Image_" . "$FILER", -bg, "--", Node => $_, tar_file => $IMAGE, ) ); } logcomment("Subtest @subtests"); Subtest::wait_finish( subtest => [@subtests] ); foreach my $subtest (@subtests) { my @results = $subtest->rslts(); foreach my $result (@results) { if ( $result->type() =~ /INFO/ ) { logcomment("Subtest Image-Installation completed successfully"); }elsif ( $result->severity() >= 0 ) { $Test->nlog("Subtest boot_filer_in_req_state not completed successfully"); if ( $result->type() =~ /FAIL/i ) { $fail_cnt++; } if ( $result->type() =~ /FATAL|SCRIPT|CONFIG/ ) { $fatal_cnt++; } } } } } if($fail_cnt||$fatal_cnt){ $test_status = 1; $email_subject = "$TC_name - $Filer_names : Test FAILED: FAIL"; $email_body = "Image installation is not done, Please check manually. \nLog Location : $LOGDIR\n"; send_message(mail_subject => $email_subject, mail_body => $email_body, MAIL_FROM => $MAIL_FROM, MAIL_TO => $MAIL_TO, EOE => $EOE, EMAIL => $EMAIL ); logresult('FAIL', "IMAGE installation is not done properly"); } }else{ $Test->description("Not installing Image on filers, user selected not to install Image"); logcomment("Not installing Image on filers, user selected not to install Image"); } ######################################################################################### if($IMAGE ne 'N'){ foreach(@Nodes){ $FILER = $_->name(); logcomment("Filer - $FILER : Booting the filer in MAINTENANCE "); my $Transit_obj = NACL::Transit->new( name => $FILER); $Transit_obj->change_state( to => "MAINT" ); destroy_root_volume(Noderef =>[$_]); } }else{ foreach(@Nodes){ my $FILER = $_->name(); my $Mode = $_->mode(); logcomment("Filer : $FILER - Changing state to MAINTENANCE"); my $Transit_obj = NACL::Transit->new( name => $FILER); $Transit_obj->change_state( to => "MAINT" ); my $Host = host($FILER); my $Api_Set_Obj = NACL::APISet->new( hostobj => $Host, category => "Node", interface => "CLI", set => "Maintenance" ); $Api_Set_Obj->execute_raw_command( command => 'version'); } } if($CONVERT_TO=~/CMode/i){ logcomment("Setting CMode Setup"); setup_cmode_filers(node_present => \@Nodes,Test => $Test,delete_mini_disk => 'NO'); }elsif($CONVERT_TO=~/7Mode/i){ logcomment("Checking for any unassigned disks"); disk_remv_assign_ownership(Node_ref => [@Nodes]); foreach(@Nodes){ ##when converting to 7Mode only one Node will be there in @Nodes my $FILER = $_->name(); logcomment("Filer : $FILER Booting in 4d"); _boot_7Mode_4d($_); } }else{ logcomment("Not Booting the filers in 4d"); } ############################################################################################ if($test_status == 0){ return $TCD::PASS; }else{ return $TCD::FAIL; } } ##################################################################### # Cleanup ##################################################################### sub cleanup() { $Test->description("Cleaning"); ####################################################### ##Copying SUBTEST logs to main directory if present return $TCD::PASS; } ######################################################################################### ## Checking the state of the filer, to find whether set-up conversion is mandatory ######################################################################################### sub _boot_7Mode_4d($){ my $Node = shift; my $FILER = $Node->name(); my $Host = host($FILER); my($default_password,$node_mgmt_ip,$net_mask,$gateway); my $Api_Set_Obj = NACL::APISet->new( hostobj => $Host, category => "Node", interface => "CLI", set => "Maintenance" ); logcomment("Filer : $FILER - Checking for disks assigned to filer"); my $return = disk_show_drive_maint(API_Obj => $Api_Set_Obj,Filer => $FILER); my @disks = @{$return->{'driveA'}}; if(!@disks){ logcomment("Filer : $FILER - WARNING : No disks available on the Filer , so not booting in 4d"); logresult('FAIL',"No disks available on the Filer"); return; }elsif(@disks <3){ logcomment("Filer : $FILER - WARNING Disks availabe are less than 3, so cannot create file-system"); logresult('FAIL',"No enough disks available on the Filer to create file-system"); return; }else{ #if($FILER_CONVERT{$FILER} =~/7Mode/i){ my $Home = $ENV{HOME}; $Home = trim($Home); my $host_file = "$Home/NDATE/FILER_INFO/$FILER"; my $filer_config = `cat $host_file`; if(!$filer_config){ logcomment("WARNING : No data found in the configuration file $host_file"); } foreach my $line ( split /\n/, $filer_config ) { $line = trim($line); if($line =~/^default_password\s*=\s*(\S+)/){ $default_password = $1; logcomment("Filer - $FILER : password of the filer is $default_password"); }elsif(($line =~ /^default_ip\s*=\s*(\S+)/)||($line =~/^MGMT_IP\s*=\s*(\S+)/)){ $node_mgmt_ip = $1; logcomment("Filer - $FILER : Ip is $node_mgmt_ip"); }elsif(($line =~ /^MASK\s*=\s*(\S+)/)||($line =~ /^MGMT_MASK\s*=\s*(\S+)/)){ $net_mask = $1; logcomment("Filer - $FILER : NET_MASK of the filer is $net_mask"); }elsif(( $line =~ /^GATEWAY\s*=\s*(\S+)/ )||( $line =~ /^MGMT_GATEWAY\s*=\s*(\S+)/ )) { $gateway = $1; logcomment("Filer - $FILER : GATEWAY of the filer is $gateway"); } } #} #--------------------------------------------------------------------- #Checking whether all required values are properly read or not #--------------------------------------------------------------------- logcomment("WARNING : IFC port not found ") if(!$default_password); logcomment("WARNING : FILER Ip not found ")if(!$node_mgmt_ip); logcomment("WARNING : Net_mask value not found ")if(!$net_mask); logcomment("WARNING : Gateway Ip not found ")if(!$gateway); #--------------------------------------------------------------------- #Checking whether all required values are properly read or not #--------------------------------------------------------------------- if((!$default_password)||(!$node_mgmt_ip )||(!$net_mask )||(!$gateway)){ logresult('FATAL',"One or more important credentials of the filer - $FILER are missing, Please check the Filer configuration file and re-run the test again"); } logcomment("Filer : $FILER - Booting the filer in 4d"); my $filer_con = connect("$FILER#console"); bootitgood_BR($filer_con,'4d',$FILER,$node_mgmt_ip,$gateway,$net_mask,$default_password,$Host); } } ############################################################### ## Setting all the Environment variables to convert the Set-up ############################################################### sub _set_environment{ foreach(@Nodes){ my $FILER = $_->name(); logcomment("Setting the environment variables based on the mode"); my ($variables_set_1,$variables_set_2); logcomment("Filer - $FILER : Converting the filer to $CONVERT_TO"); if($CONVERT_TO=~/CMode/i){ $variables_set_1 = 'set-defaults;setenv bootarg.init.boot_clustered true;setenv bootarg.init.usebootp false;setenv bootarg.init.clearvarfsnvram true;setenv bootarg.mgwd.autoconf.disable true;setenv bootarg.init.verbose 1'; $variables_set_2 = 'setenv bootarg.init.console_muted true;setenv AUTOBOOT false;setenv ONTAP_NG true;setenv bootarg.mlm.enable? true;setenv bootarg.init.cf_new false;setenv bootarg.init.nbmntcf true'; }else{ $variables_set_1 = 'set-defaults;setenv bootarg.init.usebootp false;setenv AUTOBOOT false;setenv bootarg.init.boot_clustered false'; $variables_set_2 = 'setenv bootarg.activatebsdport true;setenv bootarg.init.clearvarfsnvram false'; } my $Transit_obj = NACL::Transit->new( name => $FILER); $Transit_obj->set('timeout' => 600, maxcycle => 5); $Transit_obj->change_state( to => "FIRMWARE" ); #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ my $prompt_fw ; my $ignore_strings = ["MADIMM\\d+->","DIMM\\d+->","^T>"]; my $Host = host($FILER); my $prompt_array = $Host->prompt_fw(); my $prompts = join("|",@$prompt_array); $prompt_fw = "($prompts)"; logcomment("This is the prompt regex: $prompt_fw"); my $Server = new Server(no_cli=>1); #my $Server = new Server(nodes =>$FILER, no_cli=>1,filers_on_demand =>1); $Server->set_execution_server(-Server => $FILER); #set the execution server to the current node my @filer_working = $Server->servers(); logcomment("Number of filers working are @filer_working"); #$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ my $state = $Transit_obj->get_state('timeout' => 3600, 'get_state_timeout' => 7200); if ($state =~ /FIRMWARE/ ) { logcomment("Filer - $FILER : Setting the environment variables"); $Server->console(cmd => "$variables_set_1", additional_prompts_timeout => 60, ignore => $ignore_strings, additional_prompts => { "$prompt_fw" => "FINAL_PROMPT", } ); $Server->console(cmd => "$variables_set_2", additional_prompts_timeout => 60, ignore => $ignore_strings, additional_prompts => { "$prompt_fw" => "FINAL_PROMPT", } ); $Server->console(cmd => 'printenv', additional_prompts_timeout => 60, ignore => $ignore_strings, additional_prompts => { "$prompt_fw" => "FINAL_PROMPT", } ); }else{ logresult('FATAL',"Filer : $FILER is not in LOADER Prompt, So cannot set environment variables"); } } }