Skip to content

Commit

Permalink
ncm-nfs: Allow daemon to reload to be specified
Browse files Browse the repository at this point in the history
The name of the service/daemon is OS dependent, default to the more modern name.
For example in EL6 it was `nfs`, in EL7 `nfs` was a symlink to `nfs-server`, in EL8 only `nfs-server` exists and in Ubuntu it is `nfs-kernel-server`.
  • Loading branch information
jrha committed Sep 29, 2023
1 parent 82ba7a1 commit c8fb7de
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions ncm-nfs/src/main/pan/components/nfs/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type ${project.artifactId}_component = {
If true, missing exports forces an empty exports file and a NFS service reload.
If false, missing exports has no effect.}
'server' : boolean = true
@{ Daemon to reload when changes are made }
'daemon' : string_trimmed = 'nfs-server'
@{This is a list of dicts with "path" giving the export path and
"hosts" being a dict of host/option entries where the key is the escaped host name and
the value the export options(e.g. for "nfsclient.example.org(rw)",
Expand Down
4 changes: 2 additions & 2 deletions ncm-nfs/src/main/perl/nfs.pm
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,9 @@ sub Configure
if (! exists($tree->{server}) || $tree->{server}) {
if ($self->exports($tree)) {
# Force a reload of the nfs daemon.
$self->info("Forcing nfs reload");
$self->info("Forcing ", $tree->{daemon}, " reload");
# report error on failure
CAF::Service->new(["nfs"], log => $self)->reload();
CAF::Service->new([$tree->{daemon}], log => $self)->reload();
};
} else {
$self->verbose("Not a NFS server configuration");
Expand Down
10 changes: 9 additions & 1 deletion ncm-nfs/src/test/perl/configure.t
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use strict;
use warnings;

use Test::More;
use Test::Quattor qw(configure configure_noserver configure_nomounts);
use Test::Quattor qw(configure configure_noserver configure_nomounts configure_daemon);
use Test::MockModule;

use Test::Quattor::RegexpTest;
Expand Down Expand Up @@ -68,5 +68,13 @@ $process_mounts_arg = undef;
is($cmp->Configure($nomounts), 1, "Configure returns 1 without mounts");
ok(!defined($process_mounts_arg), "no nfs process_mounts without mounts");

# configure with alternative daemon set
my $cfgdaemon = get_config_for_profile('configure_daemon');
foreach my $change (qw(exports)){
command_history_reset();
$res = {$change => 1};
is($cmp->Configure($cfgdaemon), 1, "Configure returns 1 (change $change)");
ok(command_history_ok([qr{service nfs-server reload}]), "nfs-server service reload when $change changed");
};

done_testing();
5 changes: 5 additions & 0 deletions ncm-nfs/src/test/resources/configure_daemon.pan
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
object template configure_daemon;

include 'fstab_simple';

"/software/components/nfs/daemon" = 'nfs-server';

0 comments on commit c8fb7de

Please sign in to comment.