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
This commit is contained in:
Alexander Boettcher 2024-11-14 11:31:28 +01:00 committed by Christian Helmuth
parent 35a679d861
commit b50bbef303
3 changed files with 53 additions and 27 deletions

View File

@ -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
}

View File

@ -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"

View File

@ -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,15 +135,15 @@ proc run_power_on { } {
if {[have_installed wsman] &&
( $amt_tool == "wsman" || $amt_tool == "default") } {
amt_reset_wsman
} else {
if {[have_installed amttool] &&
} 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 {
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"
sleep [power_on_amt_timeout]