Skip to content

Commit

Permalink
Improve NFS check
Browse files Browse the repository at this point in the history
We cannot check just for an "nfs" string as there can also be
"nfs3" and "nfs4*".
  • Loading branch information
Rezney committed Aug 30, 2021
1 parent 768c9cd commit 66fcde5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions repos/system_upgrade/common/actors/checknfs/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ def process(self):
for storage in self.consume(StorageInfo):
# Check fstab
for fstab in storage.fstab:
if fstab.fs_vfstype == "nfs":
if fstab.fs_vfstype.startswith("nfs"):
nfs_found = True
details += "- One or more NFS entries in /etc/fstab\n"
break

# Check mount
for mount in storage.mount:
if mount.tp == "nfs":
if mount.tp.startswith("nfs"):
nfs_found = True
details += "- Currently mounted NFS shares\n"
break

# Check systemd-mount
for systemdmount in storage.systemdmount:
if systemdmount.fs_type == "nfs":
if systemdmount.fs_type.startswith("nfs"):
nfs_found = True
details += "- One or more configured NFS mounts in systemd-mount\n"
break
Expand Down
17 changes: 11 additions & 6 deletions repos/system_upgrade/common/actors/checknfs/tests/test_checknfs.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import pytest

from leapp.snactor.fixture import current_actor_context
from leapp.models import StorageInfo, SystemdMountEntry, FstabEntry, MountEntry
from leapp.reporting import Report


def test_actor_with_systemdmount_entry(current_actor_context):
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
def test_actor_with_systemdmount_entry(current_actor_context, nfs_fstype):
with_systemdmount_entry = [SystemdMountEntry(node="nfs", path="n/a", model="n/a",
wwn="n/a", fs_type="nfs", label="n/a",
wwn="n/a", fs_type=nfs_fstype, label="n/a",
uuid="n/a")]
current_actor_context.feed(StorageInfo(systemdmount=with_systemdmount_entry))
current_actor_context.run()
Expand All @@ -25,9 +28,10 @@ def test_actor_without_systemdmount_entry(current_actor_context):
assert not current_actor_context.consume(Report)


def test_actor_with_fstab_entry(current_actor_context):
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
def test_actor_with_fstab_entry(current_actor_context, nfs_fstype):
with_fstab_entry = [FstabEntry(fs_spec="lithium:/mnt/data", fs_file="/mnt/data",
fs_vfstype="nfs",
fs_vfstype=nfs_fstype,
fs_mntops="noauto,noatime,rsize=32768,wsize=32768",
fs_freq="0", fs_passno="0")]
current_actor_context.feed(StorageInfo(fstab=with_fstab_entry))
Expand All @@ -46,8 +50,9 @@ def test_actor_without_fstab_entry(current_actor_context):
assert not current_actor_context.consume(Report)


def test_actor_with_mount_share(current_actor_context):
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp="nfs",
@pytest.mark.parametrize('nfs_fstype', ('nfs', 'nfs4'))
def test_actor_with_mount_share(current_actor_context, nfs_fstype):
with_mount_share = [MountEntry(name="nfs", mount="/mnt/data", tp=nfs_fstype,
options="rw,nosuid,nodev,relatime,user_id=1000,group_id=1000")]
current_actor_context.feed(StorageInfo(mount=with_mount_share))
current_actor_context.run()
Expand Down

0 comments on commit 66fcde5

Please sign in to comment.