From 9d3dd5e9a2e0145dc130fd24d823c970d81764af Mon Sep 17 00:00:00 2001 From: David Lehman Date: Thu, 13 May 2021 17:08:32 -0500 Subject: [PATCH] Capture inherited volume type in return value. --- library/blivet.py | 1 + tests/tests_missing_volume_type_in_pool.yml | 76 +++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 tests/tests_missing_volume_type_in_pool.yml diff --git a/library/blivet.py b/library/blivet.py index 228df8e2..c579cbb7 100644 --- a/library/blivet.py +++ b/library/blivet.py @@ -794,6 +794,7 @@ def _get_blivet_volume(blivet_obj, volume, bpool=None): if volume_type not in _BLIVET_VOLUME_TYPES: raise BlivetAnsibleError("Volume '%s' has unknown type '%s'" % (volume['name'], volume_type)) + volume['type'] = volume_type return _BLIVET_VOLUME_TYPES[volume_type](blivet_obj, volume, bpool=bpool) diff --git a/tests/tests_missing_volume_type_in_pool.yml b/tests/tests_missing_volume_type_in_pool.yml new file mode 100644 index 00000000..96150977 --- /dev/null +++ b/tests/tests_missing_volume_type_in_pool.yml @@ -0,0 +1,76 @@ +--- +- hosts: all + become: true + vars: + storage_safe_mode: false + mount_location: '/opt/test1' + + tasks: + - include_role: + name: linux-system-roles.storage + + - include_tasks: get_unused_disk.yml + vars: + max_return: 1 + + - name: Create a partition device mounted on "{{ mount_location }}" + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: "{{ unused_disks[0] }}" + type: partition + disks: "{{ unused_disks }}" + volumes: + - name: test1 + fs_type: ext4 + mount_point: "{{ mount_location }}" + + - name: Ensure the inherited type is reflected in blivet module output + assert: + that: blivet_output.pools[0].volumes[0].type == "partition" + msg: "Incorrect type assigned to un-typed volume in partition pool" + + - include_tasks: verify-role-results.yml + + - name: Remove the partition created above + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: "{{ unused_disks[0] }}" + type: partition + disks: "{{ unused_disks }}" + state: absent + volumes: + - name: "{{ unused_disks[0] }}1" + mount_point: "{{ mount_location }}" + state: absent + + - name: Ensure the inherited type is reflected in blivet module output + assert: + that: blivet_output.pools[0].volumes[0].type == "partition" + msg: "Incorrect type assigned to un-typed volume in partition pool" + + - include_tasks: verify-role-results.yml + + - name: Repeat the previous invocation to verify idempotence + include_role: + name: linux-system-roles.storage + vars: + storage_pools: + - name: "{{ unused_disks[0] }}" + type: partition + disks: "{{ unused_disks }}" + state: absent + volumes: + - name: "{{ unused_disks[0] }}1" + mount_point: "{{ mount_location }}" + state: absent + + - name: Ensure the inherited type is reflected in blivet module output + assert: + that: blivet_output.pools[0].volumes[0].type == "partition" + msg: "Incorrect type assigned to un-typed volume in partition pool" + + - include_tasks: verify-role-results.yml