diff --git a/library/blivet.py b/library/blivet.py index 67122ea7..c94a8c71 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -1175,6 +1175,9 @@ def _create(self): if self._device: return + if self._blivet_pool._device and self._blivet_pool._device.type != "lvmvg": + raise BlivetAnsibleError("LVM volume can be placed only on LVM pool") + thin_pool = self._volume.get('thin') use_vdo = self._volume['deduplication'] or self._volume['compression'] use_lvmraid = self._volume['raid_level'] diff --git a/tests/tests_lvm_errors.yml b/tests/tests_lvm_errors.yml index b85d8696..09912679 100644 --- a/tests/tests_lvm_errors.yml +++ b/tests/tests_lvm_errors.yml @@ -194,3 +194,31 @@ type: lvm disks: "{{ unused_disks }}" state: absent + + - name: Test for correct handling of pool and volume type mismatch + include_tasks: verify-role-failed.yml + vars: + storage_safe_mode: false + __storage_failed_regex: LVM volume can be placed only on LVM pool + __storage_failed_msg: Role did not report that wrong pool type was selected + __storage_failed_params: + storage_pools: + - name: foo + disks: "{{ unused_disks }}" + type: partition + volumes: + - name: test1 + type: lvm + size: "{{ volume1_size }}" + mount_point: "{{ mount_location1 }}" + + - name: Clean up + include_role: + name: linux-system-roles.storage + vars: + storage_safe_mode: false + storage_pools: + - name: testpool1 + type: lvm + disks: "{{ unused_disks }}" + state: absent