Skip to content

Commit

Permalink
Move back collect_serial_port_log.yml as windows doesn't have serial …
Browse files Browse the repository at this point in the history
…file

Signed-off-by: Qi Zhang <[email protected]>
  • Loading branch information
keirazhang committed Jan 16, 2024
1 parent dc2a104 commit 5b65adb
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 131 deletions.
2 changes: 0 additions & 2 deletions common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,5 +193,3 @@
* get_iso_file_list.yml: Generate and validate OS installation ISO file list
* extract_errors_from_log.yml: Extract error messages in a log file downloaded from guest OS
* extract_text_from_screenshot.yml: Extract text from an image file
* collect_serial_port_log.yml: Collect VM serial port log from datastore
* vm_wait_deploy_checkpoint.yml: Wait for a checkpoint at deploy_vm
2 changes: 1 addition & 1 deletion common/extract_errors_from_log.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2023 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
---
# Extract call trace or other error messages in a log file downloaded from guest
# Extract call trace or other error messages in a log file downloaded from guest OS
# Parameters:
# local_log_path: The local log file path to extract call trace and errors
# Return:
Expand Down
87 changes: 0 additions & 87 deletions common/vm_wait_deploy_checkpoint.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
# vm_dir_name: VM directory name, which is defined in vm_get_vm_info.yml
# vm_serial_file_name: VM serial port file name, which is defined in vm_add_serial_port.yml
# vm_serial_file_local_name: the local file name of downloaded serial port log file
# Return:
# vm_serial_file_local_path: the local path to downloaded serial port log file
# detect_errors (optional): True to detect errors in serial port file. Default is false.
#
- name: "Initialize facts of downloaded serial port log file name and path"
ansible.builtin.set_fact:
Expand All @@ -21,29 +20,44 @@
- vm_serial_file_name
block:
- name: "Download VM serial port log file from datastore"
include_tasks: esxi_download_datastore_file.yml
include_tasks: ../../common/esxi_download_datastore_file.yml
vars:
src_datastore: "{{ datastore }}"
src_file_path: "{{ vm_dir_name }}/{{ vm_serial_file_name }}"
dest_file_path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}"
download_file_fail_ignore: true

- name: "Get the local path to downloaded serial port log"
- name: "Detect errors in downloaded serial port log"
when:
- detect_errors | default(false)
- file_in_datastore_result is defined
- file_in_datastore_result == 'Success'
- datastore_file_download_result.changed is defined
- datastore_file_download_result.changed
block:
- name: "Check downloaded VM serial log at local"
- name: "Set fact of downloaded serial log path at localhost"
ansible.builtin.set_fact:
vm_serial_file_local_path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}"

- name: "Check downloaded VM serial port log exists at localhost"
ansible.builtin.stat:
path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}"
path: "{{ vm_serial_file_local_path }}"
register: local_file_stat_result
ignore_errors: True

- name: "Set fact of downloaded serial log path at local"
ansible.builtin.set_fact:
vm_serial_file_local_path: "{{ current_test_log_folder }}/{{ vm_serial_file_name }}"
- name: "Detect errors from VM serial port log"
when:
- local_file_stat_result.stat.exists is defined
- local_file_stat_result.stat.exists
block:
- name: "Extract errors from VM serial port log"
include_tasks: ../../common/extract_errors_from_log.yml
vars:
local_log_path: "{{ vm_serial_file_local_path }}"

- name: "Display detected errors from VM serial port log"
ansible.builtin.debug:
msg: "{{ errors_in_log }}"
tags:
- fail_message
when: errors_in_log | length > 0
4 changes: 3 additions & 1 deletion linux/deploy_vm/deploy_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
when: vm_guest_ip is defined and vm_guest_ip
rescue:
- name: "Collect serial port log at test failure"
include_tasks: ../../common/collect_serial_port_log.yml
include_tasks: collect_serial_port_log.yml
vars:
detect_errors: true

- name: "Test case failure"
include_tasks: ../../common/test_rescue.yml
Expand Down
35 changes: 17 additions & 18 deletions linux/deploy_vm/deploy_vm_from_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,24 +143,24 @@
seconds: 5

- name: "Check 'Image APPROVED' in vmware.log when VM secure boot is enabled"
include_tasks: ../../common/vm_wait_deploy_checkpoint.yml
include_tasks: ../../common/vm_wait_log_msg.yml
vars:
wait_checkpoint_name: "secureboot"
wait_checkpoint_log_file: "vmware.log"
wait_checkpoint_msg: "SECUREBOOT: Image APPROVED"
wait_checkpoint_retires: 10
vm_wait_log_name: "vmware.log"
vm_wait_log_msg: "SECUREBOOT: Image APPROVED"
vm_wait_log_retries: 10
vm_wait_log_ignore_errors: false
vm_wait_log_hide_output: false
when:
- firmware | lower == 'efi'
- secureboot_enabled is defined and secureboot_enabled

- name: "Wait autoinstall start message appear in serial port file"
include_tasks: ../../common/vm_wait_deploy_checkpoint.yml
include_tasks: ../../common/vm_wait_log_msg.yml
vars:
wait_checkpoint_name: "autoinstall_start"
wait_checkpoint_log_file: "{{ vm_serial_file_name }}"
wait_checkpoint_msg: "{{ autoinstall_start_msg }}"
wait_checkpoint_delay: 10
wait_checkpoint_retires: 10
vm_wait_log_name: "{{ vm_serial_file_name }}"
vm_wait_log_msg: "{{ autoinstall_start_msg }}"
vm_wait_log_delay: 10
vm_wait_log_retries: 10
when:
- unattend_installer
- unattend_installer != 'Ubuntu-Subiquity'
Expand Down Expand Up @@ -203,13 +203,12 @@
when: unattend_installer == 'UOS'

- name: "Wait autoinstall complete message appear in serial port output file"
include_tasks: ../../common/vm_wait_deploy_checkpoint.yml
include_tasks: ../../common/vm_wait_log_msg.yml
vars:
wait_checkpoint_name: "autoinstall_complete"
wait_checkpoint_log_file: "{{ vm_serial_file_name }}"
wait_checkpoint_msg: "{{ autoinstall_complete_msg }}"
wait_checkpoint_delay: 30
wait_checkpoint_retires: 120
vm_wait_log_name: "{{ vm_serial_file_name }}"
vm_wait_log_msg: "{{ autoinstall_complete_msg }}"
vm_wait_log_delay: 30
vm_wait_log_retries: 120

# For only ESXi managed VM, its MAC address is generated after power on
# not at VM creation
Expand Down Expand Up @@ -253,7 +252,7 @@
when: unattend_installer is match('Ubuntu.*')

- name: "Collect serial port log before removing serial port"
include_tasks: ../../common/collect_serial_port_log.yml
include_tasks: collect_serial_port_log.yml

- name: "Remove serial port"
include_tasks: ../../common/vm_remove_serial_port.yml
Expand Down
2 changes: 1 addition & 1 deletion linux/deploy_vm/deploy_vm_from_ova.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@
include_tasks: ../utils/shutdown.yml

- name: "Collect serial port log before removing serial port"
include_tasks: ../../common/collect_serial_port_log.yml
include_tasks: collect_serial_port_log.yml

- name: "Remove serial port from VM"
include_tasks: ../../common/vm_remove_serial_port.yml
Expand Down
13 changes: 6 additions & 7 deletions linux/deploy_vm/ubuntu/ubuntu_install_os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
when: unattend_installer == 'Ubuntu-Subiquity'
block:
- name: "Wait for Ubuntu autoinstall start message"
include_tasks: ../../../common/vm_wait_deploy_checkpoint.yml
include_tasks: ../../../common/vm_wait_log_msg.yml
vars:
wait_checkpoint_name: "autoinstall_start"
wait_checkpoint_log_file: "{{ vm_serial_file_name }}"
wait_checkpoint_msg: "{{ autoinstall_start_msg }}[^\\r\\n]*"
wait_checkpoint_delay: 10
wait_checkpoint_retires: 150
vm_wait_log_name: "{{ vm_serial_file_name }}"
vm_wait_log_msg: "{{ autoinstall_start_msg }}[^\\r\\n]*"
vm_wait_log_retries: 150
vm_wait_log_delay: 5

# Ubuntu autoinstall with cloud configs requires network connection.
# When autoinstall start message is detected, its must be followed with an IPv4
Expand All @@ -26,7 +25,7 @@
ansible.builtin.set_fact:
ubuntu_autoinstall_start_ipv4: >-
{{
checkpoint_msg_list |
vm_wait_log_msg_list |
map('replace', autoinstall_start_msg, '') |
map('trim') |
ansible.utils.ipaddr('address')
Expand Down
11 changes: 6 additions & 5 deletions windows/deploy_vm/deploy_vm_from_iso.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,13 @@
minutes: 3

- name: "Check Image APPROVED in vmware.log when VM secureboot is enabled"
include_tasks: ../../common/vm_wait_deploy_checkpoint.yml
include_tasks: ../../common/vm_wait_log_msg.yml
vars:
wait_checkpoint_name: "secureboot"
wait_checkpoint_log_file: "vmware.log"
wait_checkpoint_msg: "SECUREBOOT: Image APPROVED"
wait_checkpoint_retires: 10
vm_wait_log_name: "vmware.log"
vm_wait_log_msg: "SECUREBOOT: Image APPROVED"
vm_wait_log_retries: 10
vm_wait_log_ignore_errors: false
vm_wait_log_hide_output: false
when:
- firmware | lower == 'efi'
- secureboot_enabled is defined and secureboot_enabled
Expand Down

0 comments on commit 5b65adb

Please sign in to comment.