Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common fixes tests #70

Closed
wants to merge 7 commits into from
Closed
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
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ storage_safe_mode: true # fail instead of implicitly/automatically removing dev
storage_pool_defaults:
state: "present"
type: lvm
volumes: []

storage_volume_defaults:
state: "present"
Expand Down
9 changes: 8 additions & 1 deletion library/blivet.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def _get_format(self):
fmt = get_format(self._volume['fs_type'],
mountpoint=self._volume.get('mount_point'),
label=self._volume['fs_label'],
options=self._volume['fs_create_options'])
create_options=self._volume['fs_create_options'])
if not fmt.supported or not fmt.formattable:
raise BlivetAnsibleError("required tools for file system '%s' are missing" % self._volume['fs_type'])

Expand Down Expand Up @@ -209,6 +209,8 @@ def _resize(self):
raise BlivetAnsibleError("volume '%s' cannot be resized from %s to %s: %s" % (self._device.name,
self._device.size,
size, str(e)))
elif size and self._device.size != size and not self._device.resizable:
raise BlivetAnsibleError("volume '%s' cannot be resized from %s to %s" % (self._device.name, self._device.size, size))

def _reformat(self):
""" Schedule actions as needed to ensure the volume is formatted as specified. """
Expand All @@ -224,6 +226,8 @@ def _reformat(self):

if self._device.format.status and not packages_only:
self._device.format.teardown()
if not self._device.isleaf:
self._blivet.devicetree.recursive_remove(self._device, remove_device=False)
self._blivet.format_device(self._device, fmt)

def manage(self):
Expand All @@ -247,6 +251,9 @@ def manage(self):
if self._device.exists:
self._reformat()

if self.ultimately_present and self._volume['mount_point'] and not self._device.format.mountable:
raise BlivetAnsibleError("volume '%s' has a mount point but no mountable file system" % self._volume['name'])

# schedule resize if appropriate
if self._device.exists and self._volume['size']:
self._resize()
Expand Down
5 changes: 2 additions & 3 deletions tests/tests_lvm_errors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,11 @@

- name: Test for correct handling of safe_mode with resize
block:
- name: Try to resize in safe mode
- name: Try to resize in unsafe mode
include_role:
name: storage
vars:
storage_safe_mode: no
storage_pools:
- name: testpool1
type: lvm
Expand All @@ -308,8 +309,6 @@
that: "{{ not blivet_output.failed and blivet_output.changed }}"
msg: "Unexpected behavior w/ existing data on specified disks"

when: false

- name: Test for correct handling of safe_mode with existing pool
block:
- name: Try to create LVM pool on disks that already belong to an existing pool
Expand Down