diff options
author | Abhijeet Kasurde <akasurde@redhat.com> | 2020-03-03 06:49:16 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-02 17:19:16 -0800 |
commit | f8aaa7dcd22f39594175c696edaa3322ef93ec6f (patch) | |
tree | f4f05e81c5a0a4f9d23c870c4f29c8e1fd3b6dc4 /test | |
parent | e64b120bff3961e426c4c45929d4026072f0099d (diff) | |
download | ansible-f8aaa7dcd22f39594175c696edaa3322ef93ec6f.tar.gz |
[2.9] VMware: vmware_export_ovf module fix Python3 compatibility issue (#67514)
(cherry picked from commit 023a9b31661febdff3fb7650b27ba65278971549)
Co-authored-by: Diane Wang <41371902+Tomorrow9@users.noreply.github.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/integration/targets/vmware_export_ovf/aliases | 3 | ||||
-rw-r--r-- | test/integration/targets/vmware_export_ovf/tasks/main.yml | 69 |
2 files changed, 72 insertions, 0 deletions
diff --git a/test/integration/targets/vmware_export_ovf/aliases b/test/integration/targets/vmware_export_ovf/aliases new file mode 100644 index 0000000000..3eede2cbf0 --- /dev/null +++ b/test/integration/targets/vmware_export_ovf/aliases @@ -0,0 +1,3 @@ +cloud/vcenter +shippable/vcenter/group1 +needs/target/prepare_vmware_tests diff --git a/test/integration/targets/vmware_export_ovf/tasks/main.yml b/test/integration/targets/vmware_export_ovf/tasks/main.yml new file mode 100644 index 0000000000..5bada2f74b --- /dev/null +++ b/test/integration/targets/vmware_export_ovf/tasks/main.yml @@ -0,0 +1,69 @@ +# Test code for the vmware_export_ovf module +# Copyright: (c) 2019, Diane Wang (Tomorrow9) <dianew@vmware.com> +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) + +- when: vcsim is not defined + block: + - name: create temporary build directory + tempfile: + state: directory + suffix: build + register: temp_dir + - debug: var=temp_dir + + - import_role: + name: prepare_vmware_tests + vars: + setup_attach_host: true + setup_datastore: true + setup_virtualmachines: true + + - name: set state to poweroff on the tested VM + vmware_guest: + validate_certs: False + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ virtual_machines_in_cluster[0].name }}" + state: poweredoff + + - name: export VM to ovf template + vmware_export_ovf: + validate_certs: False + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ virtual_machines_in_cluster[0].name }}" + datacenter: "{{ dc1 }}" + export_dir: "{{ temp_dir.path }}" + register: ovf_template + - debug: var=ovf_template + - name: assert the ovf template exported + assert: + that: + - "ovf_template.changed == true" + - "ovf_template.instance.device_files | length >= 1" + + - name: export VM to ovf template with timeout set + vmware_export_ovf: + validate_certs: False + hostname: "{{ vcenter_hostname }}" + username: "{{ vcenter_username }}" + password: "{{ vcenter_password }}" + name: "{{ virtual_machines_in_cluster[0].name }}" + datacenter: "{{ dc1 }}" + export_dir: "{{ temp_dir.path }}" + download_timeout: 30 + register: ovf_template + - debug: var=ovf_template + - name: assert the ovf template exported + assert: + that: + - "ovf_template.changed == true" + - "ovf_template.instance.device_files | length >= 1" + rescue: + - name: Clean up the temporary dir + file: + path: "{{ temp_dir.path }}" + state: absent + when: temp_dir.path is defined |