Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@ class BlivetDiskVolume(BlivetVolume):
blivet_device_class = devices.DiskDevice

def _get_device_id(self):
disks = self._volume.get('disks', [])
if not disks:
Comment on lines +943 to +944
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question (bug_risk): Clarify the intended behavior change when disks is missing or empty (now returning None).

Previously this would raise a KeyError/IndexError when disks was missing or empty; now it returns None. Please confirm all callers either expect None as a valid "no device" value or explicitly handle it, rather than relying on the earlier exception behavior.

return None
return self._volume['disks'][0]

def _type_check(self):
Expand Down
15 changes: 15 additions & 0 deletions tests/tests_create_multiple_partitions_dos_nvme_generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# This file was generated by generate_tests.py
- name: Run test tests_create_multiple_partitions_dos.yml for nvme
hosts: all
tags:
- tests::nvme
tasks:
- name: Set disk interface for test
set_fact:
storage_test_use_interface: "nvme"

- name: Import playbook
import_playbook: tests_create_multiple_partitions_dos.yml
tags:
- tests::nvme
15 changes: 15 additions & 0 deletions tests/tests_create_multiple_partitions_dos_scsi_generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# This file was generated by generate_tests.py
- name: Run test tests_create_multiple_partitions_dos.yml for scsi
hosts: all
tags:
- tests::scsi
tasks:
- name: Set disk interface for test
set_fact:
storage_test_use_interface: "scsi"

- name: Import playbook
import_playbook: tests_create_multiple_partitions_dos.yml
tags:
- tests::scsi
15 changes: 15 additions & 0 deletions tests/tests_create_multiple_partitions_gpt_nvme_generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# This file was generated by generate_tests.py
- name: Run test tests_create_multiple_partitions_gpt.yml for nvme
hosts: all
tags:
- tests::nvme
tasks:
- name: Set disk interface for test
set_fact:
storage_test_use_interface: "nvme"

- name: Import playbook
import_playbook: tests_create_multiple_partitions_gpt.yml
tags:
- tests::nvme
15 changes: 15 additions & 0 deletions tests/tests_create_multiple_partitions_gpt_scsi_generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
# This file was generated by generate_tests.py
- name: Run test tests_create_multiple_partitions_gpt.yml for scsi
hosts: all
tags:
- tests::scsi
tasks:
- name: Set disk interface for test
set_fact:
storage_test_use_interface: "scsi"

- name: Import playbook
import_playbook: tests_create_multiple_partitions_gpt.yml
tags:
- tests::scsi
11 changes: 11 additions & 0 deletions tests/tests_disk_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@
min_size: "10g"
max_return: 1

- name: Verify that the role fails when no disks are specified
include_tasks: verify-role-failed.yml
vars:
__storage_failed_params:
storage_volumes:
- name: test1
type: disk
mount_point: "{{ mount_location }}"
__storage_failed_regex: no disks specified for volume 'test1'
__storage_failed_msg: Role did not report that no disks were specified

- name: Verify that the role fails with the expected error message
include_tasks: verify-role-failed.yml
vars:
Expand Down
Loading