Skip to content

Commit

Permalink
Merge pull request #214 from dwlehman/missing-volume-type-inherit
Browse files Browse the repository at this point in the history
Capture inherited volume type in return value.
  • Loading branch information
dwlehman authored May 17, 2021
2 parents 804e081 + 9d3dd5e commit b3b4561
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
76 changes: 76 additions & 0 deletions tests/tests_missing_volume_type_in_pool.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b3b4561

Please sign in to comment.