#!/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 $NVMe_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 ); my ( $email_subject, $email_body ); my $TC_name; $TC_name = "1a_NADQ02_NVCLI_Basic_CMD"; ### Initialization/declaration ######################################### ######################## Global variables############################### #global variables my $test_status = 0; my $API_Object; ######################################## # Testcase available for execution ######################################### my @Testcases = ( Exe_NVME_Commands => "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_NVME_Commands { logcomment("Execute NVMe Commands from Input file "); logcomment("Create Client API "); logcomment("LOG DIR : $LOGDIR"); logcomment("MAIL TO : $MAIL_TO"); logcomment("MAIL FROM : $MAIL_FROM"); my $dsk_result = {}; 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"); my $pass = $client->{hostrec}->{conn}->{ssh}->{password}; logcomment("PASSWORD : $pass"); logcomment("Get the Client ApiSet Object"); 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 : $NVMe_FILE "); logcomment("NVMe Client : $CLIENT"); my $prompts_answers = [ ".* password for .*" => $pass ]; $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme", 'connectrec-match_table' => $prompts_answers ); open( NVM_FILE, "<$NVMe_FILE " ) or print ">>>>> read: Failed opening $NVMe_FILE<<<<<"; foreach my $line () { chomp($line); next if ( $line =~ /#/ ); logcomment("Executing command $line "); $Api_Set_Client->execute_raw_command( 'command' => $line ); } my $prompts_answers = [ ".* password for .*" => $pass ]; my $output = $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme list", 'connectrec-match_table' => $prompts_answers ); my @lines = split( /\n/, $output ); foreach my $line (@lines) { next if ( $line =~ /--|Node/ ); if ( $line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*\/.*GB|TB|MB)\s+(.*\+.*)\s+(\S+)/ ) { my ( $disk, $serial, $vendor, $model, $nspace, $usage, $format, $fwrev ) = ( $line =~ /(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.*\/.*GB|TB|MB)\s+(.*\+.*)\s+(\S+)/ ); $dsk_result->{$disk} = { 'DISK' => $disk, 'SERIAL' => $serial, 'VENDOR' => $vendor, 'MODEL' => $model, 'NSPACE' => $nspace, 'USAGE' => $usage, 'FORMAT' => $format, 'FWREV' => $fwrev, }; } } logcomment("Captureed Drive details :"); #logcomment( "dumoing " . Dumper($dsk_result) ); my @disk_list = keys(%$dsk_result); logcomment("Drives Present : @disk_list"); #STEP 1 eye_catcher( Test => $Test, string => "Show REG" ); foreach my $drv (@disk_list) { logcomment("Show reg for Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme show-regs $drv" ); } ## eye_catcher( Test => $Test, string => "Show REG -H : Human Readable" ); foreach my $drv (@disk_list) { logcomment("Show reg for Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme show-regs $drv -H" ); } ## eye_catcher( Test => $Test, string => "List CTRL" ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme list-ctrl $drv " ); } ## eye_catcher( Test => $Test, string => "Drive Indentify controller " ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme id-ctrl $drv " ); } ## eye_catcher( Test => $Test, string => "Drive Indentify controller : Human Readable" ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme id-ctrl $drv -H " ); } ## eye_catcher( Test => $Test, string => "Get NVME name space ID" ); foreach my $drv (@disk_list) { logcomment(" Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme get-ns-id $drv " ); } ## eye_catcher( Test => $Test, string => "Get NVME name space details" ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme id-ns $drv " ); } ## eye_catcher( Test => $Test, string => "Get NVME name space details Human Readable format" ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme id-ns $drv -H" ); } ## eye_catcher( Test => $Test, string => "Get firmware slots" ); foreach my $drv (@disk_list) { logcomment("Drive : $drv "); $Api_Set_Client->execute_raw_command( 'command' => "sudo nvme fw-log $drv" ); } ## return $TCD::PASS; }