diff --git a/lib/auxiliary/host_helper.rb b/lib/auxiliary/host_helper.rb index 0b068db4..34fda810 100644 --- a/lib/auxiliary/host_helper.rb +++ b/lib/auxiliary/host_helper.rb @@ -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 diff --git a/lib/setupmanagers/qemuhck/qemu_machine.rb b/lib/setupmanagers/qemuhck/qemu_machine.rb index 1466dafd..1ab84371 100644 --- a/lib/setupmanagers/qemuhck/qemu_machine.rb +++ b/lib/setupmanagers/qemuhck/qemu_machine.rb @@ -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 @@ -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@', @@ -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) @@ -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 = [ diff --git a/lib/setupmanagers/qemuhck/qemuhck.rb b/lib/setupmanagers/qemuhck/qemuhck.rb index e3410251..1179c72b 100644 --- a/lib/setupmanagers/qemuhck/qemuhck.rb +++ b/lib/setupmanagers/qemuhck/qemuhck.rb @@ -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 @@ -24,6 +25,7 @@ def initialize(project) @clients_vm = {} initialize_studio_vm initialize_clients_vm + write_host_info end def initialize_project(project) @@ -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