#!/usr/software/bin/perl # $Id: # $ # Copyright (c) 2005 Network Appliance, Inc. # All rights reserved # ## @summary Mode ## ######################################### # Compiler directives. use strict; # Module imports use TCD; use NACL::APISet; use NACL::C::Node; use Data::Dumper; use NACL::APISet::Host; use NACL::Transit; use Storage::Common_Lib; 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 $MAIL_TO $MAIL_FROM $EMAIL $FILER_TYPE $Primary_Node $CLIENTS $INPUT_FILE ); param( 'CLIENTS', -mesg, "hostspec of the nvme_cli" ); param( 'MAIL_TO', -mesg, "Email To" ); param( 'MAIL_FROM', -mesg, "Email from" ); my $params = NATE::ParamSet->new( global => 1 ); $LOGDIR = $params->get( 'LOGDIR', default => undef ); $EOE = $params->get( 'EOE', default => 'default' ); $EMAIL = $params->get( 'EMAIL', default => 'y' ); $MAIL_TO = $params->get( 'MAIL_TO', default => 'Email to' ); $MAIL_FROM = $params->get( 'MAIL_FROM', default => 'Email from' ); $CLIENTS = $params->get( 'CLIENTS', default => undef ); $INPUT_FILE = $params->get( 'INPUT_FILE', default => 'NVMe file not entered' ); my ( $email_subject, $email_body ); my $TC_name; $TC_name = "1b_NADQ02_NVCLI_CMD_FILE"; ### Initialization/declaration ######################################### ######################## Global variables############################### #global variables my $test_status = 0; my $API_Object; ######################################## # Testcase available for execution ######################################### my @Testcases = ( Exe_CMD => "Execute NVMe CLI Commands" ); ######################################### ## Pre-test processes ########################################## ########################################## &main(); sub main { # Debug break point $DB::single = 2; # Create Test Case Driver object $Test = new TCD( -testcases => [@Testcases] ); # Testcases will be executed using TCD object. if ( $Test->error ) { $Test->log( $Test->errmsg ); return $TCD::FAIL; } # Performs method callbacks $Test->run_test(); if ( $Test->error ) { $Test->log( $Test->errmsg ); return $TCD::FAIL; } exit(0); } ## end sub main ########## INIT ################################################### # This init subroutine will initialise the filer. #################################################################### sub init() { $Test->description(" Initialising all required variables and filer connections "); return $TCD::PASS; } sub setup() { $Test->description("Setup the environment for the test exectuion "); return $TCD::PASS; } ########## TEST 1 ################################################### #Exe_NVME_Commands ##################################################################### sub Exe_CMD { $Test->description("Execute Commands availabe from input file"); logcomment("Create Client API "); my $client = NACL::C::Client->find(); logcomment("Get the first client name passed via ntest"); my $client_name = $client->hostrec->hostname; logcomment("Client name = $client_name"); logcomment("Get the Client ApiSet Object"); logcomment("Client name = $client_name"); my $pass = $client->{hostrec}->{conn}->{ssh}->{password}; logcomment("PASSWORD : $pass"); my $Api_Set_Client = NACL::APISet->new( name => $client_name, category => 'Host', interface => 'CLI', set => 'Linux', connid => 'ssh' ); logcomment("Get all user parameters"); logcomment("NVME-CLI - command File : $INPUT_FILE"); logcomment("NVMe Client : $INPUT_FILE"); open( NVM_FILE, "<$INPUT_FILE" ) or die ">>>>> read: Failed opening $INPUT_FILE<<<<<"; foreach my $line () { chomp($line); next if ( $line =~ /#/ ); logcomment("Executing command $line "); my $prompts_answers = [ ".* password for .*" => $pass ]; eye_catcher(Test=>$Test,string =>"EXECUTING COMMAND : $line"); $Api_Set_Client->execute_raw_command( 'command' => "\013"); $Api_Set_Client->execute_raw_command( 'command' => $line , 'connectrec-match_table' => $prompts_answers); $Api_Set_Client->execute_raw_command( 'command' => "\013"); logcomment("Wait for 2 seconds"); sleep 3; $Api_Set_Client->execute_raw_command( 'command' => "\013"); eye_catcher(Test=>$Test,string =>"### END OF COMMAND ###"); } return $TCD::PASS; }