genode/tool/run/log/amt
Alexander Boettcher b50bbef303 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
2024-11-26 18:17:41 +01:00

122 lines
3.3 KiB
Plaintext

##
# Get output of the target machine via Intel AMT's SoL feature
#
# \param --log-amt-host network address of target machine
# \param --log-amt-password AMT password for target machine
# \param --log-amt-filter Sanitize output by piping it through a filter
# \param --log-amt-skip-test Skip AMT SOL availability test
#
source [genode_dir]/tool/run/log.inc
source [genode_dir]/tool/run/amt.inc
proc log_amt_host { } {
return [get_cmd_arg_first --log-amt-host ""]
}
proc log_amt_password { } {
return [get_cmd_arg_first --log-amt-password ""]
}
proc log_amt_filter { } {
return [get_cmd_arg_first --log-amt-filter ""]
}
proc log_amt_timeout { } {
return [get_cmd_arg_first --log-amt-timeout "30"]
}
proc log_amt_skip_test { } {
return [get_cmd_switch --log-amt-skip-test]
}
##
# Log output of the test machine using Intel's AMT
#
proc run_log { wait_for_re timeout_value } {
global output_spawn_id
if {![is_amt_available [log_amt_host] [log_amt_password]]} {
set exit_result 1
return false
}
set amt_tool [get_cmd_arg --amt-tool "default"]
# Check that SOL is correctly configured if wsman is available
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]
if {![regexp {ListenerEnabled>true} $redir_state]} {
puts " Warning: AMT_RedirectionService listener is disabled - serial output will not be available"
puts " Use wsman to enable the listener service, e.g.:"
puts " wsman put http://intel.com/wbem/wscim/1/amt-schema/1/AMT_RedirectionService -h [log_amt_host] -P 16992 -u admin -p <your-intel-me-amt-password> -k ListenerEnabled=true"
puts ""
}
} else {
puts " Warning: could not check AMT SOL redirection service because of missing wsman tool, --amt-tool==$amt_tool"
}
}
if {$wait_for_re == "forever"} {
set timeout -1
} else {
set timeout [expr $timeout_value + [log_amt_timeout]]
}
set exit_result 1
#
# 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"
return false
}
set kernel_msg [run_boot_string]
expect {
-i $output_spawn_id $kernel_msg { }
eof {
puts stderr "Aborting, received EOF"
return false
}
timeout {
puts stderr "Boot process timed out"
close -i $output_spawn_id; wait
return false
}
}
wait_for_output $wait_for_re $timeout_value $output_spawn_id
return true
}