Skip to content

Commit

Permalink
Adding test case to create VM using unattend xml file (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
george-ghawali authored Dec 16, 2024
1 parent 2be9a6f commit f3d47c4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,46 @@
ansible.builtin.set_fact:
todelete: '{{ todelete + [result["ext_id"]] }}'
########################################################################

- name: Read content from file
ansible.builtin.set_fact:
xml_file_content: "{{ lookup('file', unattendxml.dest + '/unattendxml.txt') }}"

- name: Create vm with windows unattend xml file
ntnx_vms_v2:
name: "{{ vm_name }}"
description: ansible test
cluster:
ext_id: "{{ cluster.uuid }}"
guest_customization:
config:
sysprep:
install_type: "FRESH"
sysprep_script:
unattendxml:
value: "{{ xml_file_content }}"
register: result
ignore_errors: true

- name: Creation status
ansible.builtin.assert:
that:
- result.response is defined
- result.changed == True
- result.failed == False
- result.response.ext_id is defined
- result.response.cluster.ext_id == "{{ cluster.uuid }}"
- result.response.name == "{{ vm_name }}"
- result.response.cd_roms[0] is defined
- result.response.cd_roms[0].iso_type == "GUEST_CUSTOMIZATION"
fail_msg: " Unable to create VM with windows unattend xml file "
success_msg: " VM with windows unattend xml file created successfully "

- name: Adding VM to todelete list
ansible.builtin.set_fact:
todelete: '{{ todelete + [result["ext_id"]] }}'

########################################################################
- name: List all VMs
ntnx_vms_info_v2:
register: result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,10 @@
mode: "0644"
url: "{{ xml_content.url }}"
dest: "{{ xml_content.dest }}"

- name: Downloading unattendxml file for windows tests
ansible.builtin.get_url:
mode: "0644"
url: "{{ unattendxml.url }}"
dest: "{{ unattendxml.dest }}"

Check failure on line 225 in tests/integration/targets/prepare_env/playbooks/prepare_env.yml

View workflow job for this annotation

GitHub Actions / Ansible Lint

yaml[empty-lines]

Too many blank lines (1 > 0)

0 comments on commit f3d47c4

Please sign in to comment.