Whamcloud - gitweb
LU-17662 osd-zfs: Support for ZFS 2.2.3
[fs/lustre-release.git] / lustre / tests / setup-nfs.sh
1 #!/bin/bash
2
3 DEFAULT_NFS_OPTIONS=${DEFAULT_NFS_OPTIONS:-"rw,async,no_root_squash"}
4 DEFAULT_EXPORTS_FILE=${DEFAULT_EXPORTS_FILE:-"/etc/exports.d/lustre.exports"}
5
6 setup_nfs() {
7         local LUSTRE_CLIENT=$1
8         local LUSTRE_MOUNT_POINT=$2
9         local NFS_CLIENTS=$3
10         local NFS_MOUNT_POINT=$4
11         local NFS_VERSION=$5
12         local EXPORTS_FILE=$DEFAULT_EXPORTS_FILE
13         local NFS_OPTIONS=$DEFAULT_NFS_OPTIONS
14
15         echo "Exporting Lustre filesystem via NFS version $NFS_VERSION"
16         do_nodes "$LUSTRE_CLIENT" \
17                 "echo '$LUSTRE_MOUNT_POINT *($NFS_OPTIONS)' | \
18                 tee $EXPORTS_FILE" || return 1
19         do_nodes "$LUSTRE_CLIENT" "systemctl restart nfs-server" || return 1
20         do_nodes "$LUSTRE_CLIENT" "systemctl restart nfs-idmapd" || return 1
21
22         echo "Mounting NFS clients version $NFS_VERSION"
23         do_nodes "$NFS_CLIENTS" "systemctl restart nfs-idmapd" || return 1
24         do_nodes "$NFS_CLIENTS" "mkdir -p $NFS_MOUNT_POINT" || return 1
25         do_nodes "$NFS_CLIENTS" \
26                 "mount -v -t nfs -o nfsvers=$NFS_VERSION,async \
27                 $LUSTRE_CLIENT:$LUSTRE_MOUNT_POINT \
28                 $NFS_MOUNT_POINT" || return 1
29
30         return 0
31 }
32
33 cleanup_nfs() {
34         local LUSTRE_CLIENT=$1
35         local LUSTRE_MOUNT_POINT=$2
36         local NFS_CLIENTS=$3
37         local NFS_MOUNT_POINT=$4
38         local EXPORTS_FILE=$DEFAULT_EXPORTS_FILE
39
40         echo "Unmounting NFS clients"
41         zconf_umount_clients "$NFS_CLIENTS" $NFS_MOUNT_POINT -f || return 1
42         do_nodes "$NFS_CLIENTS" "systemctl stop nfs-idmapd" || return 1
43
44         echo "Unexporting Lustre filesystem"
45         do_nodes "$LUSTRE_CLIENT" "systemctl stop nfs-server" || return 1
46         do_nodes "$LUSTRE_CLIENT" "systemctl stop nfs-idmapd" || return 1
47         do_nodes "$LUSTRE_CLIENT" "rm -v $EXPORTS_FILE" || return 1
48 }