Skip to content

Commit

Permalink
Add host.txt file with host and VM's information
Browse files Browse the repository at this point in the history
Signed-off-by: Vitalii Chulak <[email protected]>
  • Loading branch information
Jedoku committed May 13, 2024
1 parent 2192c6f commit 61bfea4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 4 deletions.
12 changes: 12 additions & 0 deletions lib/auxiliary/host_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,17 @@ def file_gsub(src, dst, gsub_list)
end
File.write(dst, content)
end

def parse_os_release
os_info = {}
File.readlines('/etc/os-release').each do |line|
if line.start_with?('NAME=')
os_info[:name] = line.split('=').last.strip.tr('"', '')
elsif line.start_with?('VERSION=')
os_info[:version] = line.split('=').last.strip.tr('"', '')
end
end
"NAME: #{os_info[:name]}, VERSION: #{os_info[:version]}"
end
end
end
9 changes: 5 additions & 4 deletions lib/setupmanagers/qemuhck/qemu_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ def check_fails_too_quickly(status)
end
end

def run_vm
@machine.dump_config
def run_vm # rubocop:disable Metrics/AbcSize
@logger.info(@machine.dump_config)

@qemu_thread = Thread.new do
loop do
Expand Down Expand Up @@ -545,6 +545,7 @@ def find_world_ip
def dump_config
config = [
'Setup configuration:',
" VM name .................... CL#{@options['client_id']}",
' Setup ID ................... @run_id@',
' Machine type ............... @machine_name@',
' QEMU binary ................ @qemu_bin@',
Expand Down Expand Up @@ -573,7 +574,7 @@ def dump_config
# S3 enabled..................${ENABLE_S3}
# S4 enabled..................${ENABLE_S4}
# Snapshot mode.............. ${SNAPSHOT}
@logger.info(replace_string_recursive(config.join("\n"), full_replacement_list))
replace_string_recursive(config.join("\n"), full_replacement_list)
end

def create_run_script(file_name, file_content)
Expand Down Expand Up @@ -644,7 +645,7 @@ def merge_commands_array(arr)
end

def dump_commands
dump_config
@logger.info(dump_config)

file_name = "#{@workspace_path}/#{@run_name}_manual.sh"
content = [
Expand Down
31 changes: 31 additions & 0 deletions lib/setupmanagers/qemuhck/qemuhck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class QemuHCK

attr_reader :kit, :project

HOST_INFO_LOG_FILE = 'host.txt'
OPT_NAMES = %w[viommu_state s3_state s4_state enlightenments_state vhost_state machine_type fw_type cpu
pluggable_memory_gb].freeze

Expand All @@ -24,6 +25,7 @@ def initialize(project)
@clients_vm = {}
initialize_studio_vm
initialize_clients_vm
write_host_info
end

def initialize_project(project)
Expand Down Expand Up @@ -108,6 +110,35 @@ def initialize_clients_vm
end
end

def write_host_info
host_log = "#{@workspace_path}/#{HOST_INFO_LOG_FILE}"
File.write(host_log, collect_environment_info.join("\n"))
@project.result_uploader.upload_file(host_log, HOST_INFO_LOG_FILE)
end

def collect_environment_info
logs = []
compose_host_info(logs)
compose_vms_info(logs)
logs
end

def compose_host_info(logs)
logs << "QEMU version: #{`qemu-system-x86_64 --version`.lines.first.strip}"
logs << "Linux OS info: #{parse_os_release}"
logs << "System information: #{`uname -a`.strip}"
logs << 'Studio Properties:'
logs << "\n"
end

def compose_vms_info(logs)
logs << " #{@studio_vm.dump_config} \n"
@platform['clients'].each_with_index do |(_k, v), i|
logs << "Client #{i + 1} Propertties:"
logs << " #{@clients_vm[v['name']].dump_config} \n"
end
end

def check_studio_image_exist
@studio_vm.check_image_exist
end
Expand Down

0 comments on commit 61bfea4

Please sign in to comment.