From b50bbef3036e5e656eadf5e04e83937012149728 Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Thu, 14 Nov 2024 11:31:28 +0100 Subject: [PATCH] tool: support meshcmd as AMT alternative tool which may be used as alternative for - AMT log grabbing, default: amtterm - AMT power cycling, default: wsman, alternative: amttool https://www.meshcommander.com https://github.com/Ylianst/MeshCommander https://www.intel.com/content/www/us/en/developer/articles/news/meshcmd-new-intel-amt-command-line-tool.html --- tool/run/amt.inc | 4 ++++ tool/run/log/amt | 46 +++++++++++++++++++++++++------------------ tool/run/power_on/amt | 30 ++++++++++++++++++++-------- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/tool/run/amt.inc b/tool/run/amt.inc index 62d887caec..4fc882df2b 100644 --- a/tool/run/amt.inc +++ b/tool/run/amt.inc @@ -23,6 +23,10 @@ proc is_amt_available { {host "" } {password "" } } { return true } + if {[have_installed meshcmd]} { + return true + } + puts "No support for Intel's AMT detected." return false } diff --git a/tool/run/log/amt b/tool/run/log/amt index f20b015a8d..0f95758051 100644 --- a/tool/run/log/amt +++ b/tool/run/log/amt @@ -44,11 +44,11 @@ proc run_log { wait_for_re timeout_value } { return false } - set amt_tool [get_cmd_arg --amt-tool "wsman"] + set amt_tool [get_cmd_arg --amt-tool "default"] # Check that SOL is correctly configured if wsman is available - if {![log_amt_skip_test]} { - if {[have_installed wsman] && $amt_tool=="wsman" } { + if {![log_amt_skip_test] && ( $amt_tool == "wsman" || $amt_tool == "default" )} { + if {[have_installed wsman]} { puts "Test for working AMT SOL redirection service ..." set redir_state [exec wsman get http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RedirectionService -h [log_amt_host] -P 16992 -u admin -p [log_amt_password]] set redir_state [regexp -inline {ListenerEnabled.*ListenerEnabled} $redir_state] @@ -62,21 +62,6 @@ proc run_log { wait_for_re timeout_value } { } else { puts " Warning: could not check AMT SOL redirection service because of missing wsman tool, --amt-tool==$amt_tool" } - } else { - puts "Skipping test for working AMT SOL redirection service" - } - - # - # password via environment variable for amtterm will not show up in logs - # - set ::env(AMT_PASSWORD) [log_amt_password] - - # - # grab output - # - set amt_cmd "amtterm -u admin -v [log_amt_host]" - if {[get_cmd_switch --log-amt-filter]} { - set amt_cmd "$amt_cmd | [log_amt_filter]" } if {$wait_for_re == "forever"} { @@ -86,7 +71,30 @@ proc run_log { wait_for_re timeout_value } { } set exit_result 1 - lassign [retry 30 "/bin/sh -c \"$amt_cmd\"" ".*session authentication" 0.5] retry_output output_spawn_id + # + # prepare command + # + if {[have_installed meshcmd] && ( $amt_tool == "meshcmd" )} { + set amt_cmd "meshcmd amtterm --host [log_amt_host] --password [log_amt_password]" + set amt_log ".*Connected" + } else { + # + # password via environment variable for amtterm will not show up in logs + # + set ::env(AMT_PASSWORD) [log_amt_password] + + set amt_cmd "amtterm -u admin -v [log_amt_host]" + set amt_log ".*session authentication" + } + + if {[get_cmd_switch --log-amt-filter]} { + set amt_cmd "$amt_cmd | [log_amt_filter]" + } + + # + # grab output + # + lassign [retry 30 "/bin/sh -c \"$amt_cmd\"" "$amt_log" 2] retry_output output_spawn_id if {$retry_output == ""} { puts stderr "Aborting, AMT SOL not accessible" diff --git a/tool/run/power_on/amt b/tool/run/power_on/amt index c9d9f2ac7c..da31f6e97f 100644 --- a/tool/run/power_on/amt +++ b/tool/run/power_on/amt @@ -102,6 +102,20 @@ proc amt_reset_wsman { } { } +## +# Reset via meshcmd +# Executes a power on or power cycle depending on the current power state +# +proc amt_reset_meshcmd { } { + set power_state [exec meshcmd amtpower --reset --host [power_on_amt_host] --password [power_on_amt_password]] + if { $power_state == "Current power state: Soft off" } { + exec meshcmd amtpower --powercycle --host [power_on_amt_host] --password [power_on_amt_password] + } else { + exec meshcmd amtpower --poweron --host [power_on_amt_host] --password [power_on_amt_password] + } +} + + ## # Reset the test machine using Intel's AMT # @@ -111,7 +125,7 @@ proc run_power_on { } { } # - # amttool and wsman are supported for reset + # amttool, wsman and meshcmd are supported for reset # set amt_tool [get_cmd_arg --amt-tool "default"] @@ -121,14 +135,14 @@ proc run_power_on { } { if {[have_installed wsman] && ( $amt_tool == "wsman" || $amt_tool == "default") } { amt_reset_wsman + } elseif {[have_installed meshcmd] && ( $amt_tool == "meshcmd" )} { + amt_reset_meshcmd + } elseif {[have_installed amttool] && + ( $amt_tool == "amttool" || $amt_tool == "default") } { + amt_reset_soap_eoi } else { - if {[have_installed amttool] && - ($amt_tool == "amttool" || $amt_tool == "default") } { - amt_reset_soap_eoi - } else { - puts stderr "specified tool \"$amt_tool\" for using Intel AMT is unknown or is not installed" - exit -1 - } + puts stderr "specified tool \"$amt_tool\" for using Intel AMT is unknown or is not installed" + exit -1 } puts "wait [power_on_amt_timeout] seconds for power on"