Skip to content

Commit

Permalink
Merge pull request #429 from nutanix/bug/fix-backward-compatibility-i…
Browse files Browse the repository at this point in the history
…n-vm-disks

Bug/fix backward compatibility in vm disks
  • Loading branch information
alaa-bish authored Nov 1, 2023
2 parents 236af45 + 94b969c commit 78929dd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/module_utils/prism/vms.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,6 @@ def _generate_disk_spec(
msg="Unsupported operation: Unable to decrease disk size.",
disk=disk,
)
elif not vdisk.get("uuid"):
self.module.fail_json(
msg="Unsupported operation: Unable to create disk, 'size_gb' is required.",
disk=disk,
)

if vdisk.get("storage_container"):
disk.pop("data_source_reference", None)
Expand All @@ -491,6 +486,11 @@ def _generate_disk_spec(
return None, error

disk["storage_config"]["storage_container_reference"]["uuid"] = uuid
if not vdisk.get("uuid") and not vdisk.get("size_gb"):
self.module.fail_json(
msg="Unsupported operation: Unable to create disk, 'size_gb' is required for using storage container.",
disk=disk,
)

elif vdisk.get("clone_image"):
uuid, error = get_image_uuid(vdisk["clone_image"], self.module)
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/targets/nutanix_vms/tasks/negtaive_scenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,36 @@
- result.error == "Project project not found."
success_msg: ' Success: returned error as expected '
#############################################################
- name: Check if error is produced when disk size is not given for storage container
check_mode: yes
ntnx_vms:
state: present
name: VM with storage container
timezone: GMT
cluster:
name: "{{ cluster.name }}"
categories:
AppType:
- Apache_Spark
disks:
- type: DISK
bus: SCSI
storage_container:
name: "{{ storage_container.name }}"
vcpus: 1
cores_per_vcpu: 1
memory_gb: 1
register: result
ignore_errors: True

- name: Creation Status
assert:
that:
- result.msg == "Unsupported operation: Unable to create disk, 'size_gb' is required for using storage container."
- result.failed == True
- result.failed is defined
success_msg: ' Success: returned error as expected '
##################################################################################
- name: Unknown Cluster
ntnx_vms:
state: present
Expand Down

0 comments on commit 78929dd

Please sign in to comment.