Skip to content

Commit

Permalink
fix disks issue when size gb is not given for clone image disks
Browse files Browse the repository at this point in the history
  • Loading branch information
bhati-pradeep committed Nov 1, 2023
1 parent 2fae70f commit 94b969c
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 94b969c

Please sign in to comment.