From 4466d6d0954148401e7b8d14fb8615de708d83fd Mon Sep 17 00:00:00 2001 From: ZouYuhua Date: Fri, 30 Jun 2023 22:36:58 +0800 Subject: [PATCH 1/3] The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 Signed-off-by: ZouYuhua --- .../reconfigure_vm_with_cloudinit.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml index 3ba3221de..ae8fe5e07 100644 --- a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml +++ b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml @@ -154,6 +154,25 @@ remove_serial_port.changed is undefined or not remove_serial_port.changed + - name: "Get all CDROM devices on VM after poweroff" + include_tasks: ../../common/vm_get_cdrom_devices.yml + + # The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 + - name: "Remove all CDROM" + include_tasks: ../../common/vm_configure_cdrom.yml + vars: + cdrom_type: client + cdrom_controller_type: "{{ vm_cdrom.controller_label.split()[0] | lower }}" + cdrom_controller_num: "{{ vm_cdrom.bus_num }}" + cdrom_unit_num: "{{ vm_cdrom.unit_num }}" + cdrom_state: absent + with_items: "{{ cdrom_device_list }}" + loop_control: + loop_var: vm_cdrom + when: + - cdrom_device_list is defined + - cdrom_device_list | length > 0 + - name: "Power on VM" include_tasks: ../../common/vm_set_power_state.yml vars: From 4e3845e0b83c4de7c223e44efe358de9100af64a Mon Sep 17 00:00:00 2001 From: ZouYuhua Date: Mon, 3 Jul 2023 13:44:26 +0800 Subject: [PATCH 2/3] modify as codereview Signed-off-by: ZouYuhua --- .../reconfigure_vm_with_cloudinit.yml | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml index ae8fe5e07..0139aef7c 100644 --- a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml +++ b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml @@ -133,7 +133,23 @@ cdrom_controller_num: "{{ vm_cdrom_controller_num }}" cdrom_unit_num: "{{ vm_cdrom_unit_num }}" cdrom_state: absent - when: cdrom_device_list | length > vm_existing_cdrom_list | length + when: + - ova_guest_os_type != 'ubuntu' + - cdrom_device_list | length > vm_existing_cdrom_list | length + + # The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 + - name: "Remove all CDROM" + include_tasks: ../../common/vm_configure_cdrom.yml + vars: + cdrom_type: client + cdrom_controller_type: "{{ vm_cdrom.controller_label.split()[0] | lower }}" + cdrom_controller_num: "{{ vm_cdrom.bus_num }}" + cdrom_unit_num: "{{ vm_cdrom.unit_num }}" + cdrom_state: absent + with_items: "{{ cdrom_device_list }}" + loop_control: + loop_var: vm_cdrom + when: ova_guest_os_type == 'ubuntu' when: - cdrom_device_list is defined - cdrom_device_list | length > 0 @@ -154,25 +170,6 @@ remove_serial_port.changed is undefined or not remove_serial_port.changed - - name: "Get all CDROM devices on VM after poweroff" - include_tasks: ../../common/vm_get_cdrom_devices.yml - - # The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 - - name: "Remove all CDROM" - include_tasks: ../../common/vm_configure_cdrom.yml - vars: - cdrom_type: client - cdrom_controller_type: "{{ vm_cdrom.controller_label.split()[0] | lower }}" - cdrom_controller_num: "{{ vm_cdrom.bus_num }}" - cdrom_unit_num: "{{ vm_cdrom.unit_num }}" - cdrom_state: absent - with_items: "{{ cdrom_device_list }}" - loop_control: - loop_var: vm_cdrom - when: - - cdrom_device_list is defined - - cdrom_device_list | length > 0 - - name: "Power on VM" include_tasks: ../../common/vm_set_power_state.yml vars: From 34cbf2b52ae5391b71915275e37079595840e5e3 Mon Sep 17 00:00:00 2001 From: ZouYuhua Date: Mon, 3 Jul 2023 14:27:33 +0800 Subject: [PATCH 3/3] It's not supported to hot-reomve IDE CDROM Signed-off-by: ZouYuhua --- .../reconfigure_vm_with_cloudinit.yml | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml index 0139aef7c..21ba76c6d 100644 --- a/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml +++ b/linux/deploy_vm/reconfigure_vm_with_cloudinit.yml @@ -133,23 +133,7 @@ cdrom_controller_num: "{{ vm_cdrom_controller_num }}" cdrom_unit_num: "{{ vm_cdrom_unit_num }}" cdrom_state: absent - when: - - ova_guest_os_type != 'ubuntu' - - cdrom_device_list | length > vm_existing_cdrom_list | length - - # The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 - - name: "Remove all CDROM" - include_tasks: ../../common/vm_configure_cdrom.yml - vars: - cdrom_type: client - cdrom_controller_type: "{{ vm_cdrom.controller_label.split()[0] | lower }}" - cdrom_controller_num: "{{ vm_cdrom.bus_num }}" - cdrom_unit_num: "{{ vm_cdrom.unit_num }}" - cdrom_state: absent - with_items: "{{ cdrom_device_list }}" - loop_control: - loop_var: vm_cdrom - when: ova_guest_os_type == 'ubuntu' + when: cdrom_device_list | length > vm_existing_cdrom_list | length when: - cdrom_device_list is defined - cdrom_device_list | length > 0 @@ -170,6 +154,20 @@ remove_serial_port.changed is undefined or not remove_serial_port.changed + # The workaround "Remove CDROM" for issue: https://bugs.launchpad.net/cloud-init/+bug/1992509 + - name: "Remove all CDROM" + include_tasks: ../../common/vm_configure_cdrom.yml + vars: + cdrom_type: client + cdrom_controller_type: "{{ vm_cdrom.controller_label.split()[0] | lower }}" + cdrom_controller_num: "{{ vm_cdrom.bus_num }}" + cdrom_unit_num: "{{ vm_cdrom.unit_num }}" + cdrom_state: absent + with_items: "{{ vm_existing_cdrom_list }}" + loop_control: + loop_var: vm_cdrom + when: vm_existing_cdrom_list | length > 0 + - name: "Power on VM" include_tasks: ../../common/vm_set_power_state.yml vars: