Whamcloud - gitweb
LU-10866 pacemaker: Support additional mount options
[fs/lustre-release.git] / lustre / conf / resource / Lustre
index 645bf96..fc251fe 100755 (executable)
@@ -4,7 +4,7 @@
 # Description:  Manages Lustre server on a shared storage
 # Written by:   Gabriele Paciucci, Nathaniel Clark
 # Release Date: 28 February 2017
-# Release Version: 1.0.0
+# Release Version: 1.0.1
 # Copyright (c) 2017, Intel Corporation
 #
 # This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,7 @@
 #               OCF parameters are as follows:
 #               OCF_RESKEY_target - the device or ZFS volume to mount/umount
 #               OCF_RESKEY_mountpoint - the mountpoint to use
+#               OCF_RESKEY_mountoptions - any mount options to use
 #######################################################################
 # Initialization:
 
@@ -37,7 +38,7 @@
 # USAGE
 
 usage() {
-    usage: $0 {start|stop|status|monitor|validate-all|meta-data}
+    echo "usage: $0 {start|stop|status|monitor|validate-all|meta-data}"
 }
 
 # META-DATA
@@ -47,7 +48,7 @@ meta_data() {
 <?xml version="1.0"?>
 <!DOCTYPE resource-agent SYSTEM "ra-api-1.dtd">
 <resource-agent name="Lustre">
-<version>1.0.0</version>
+<version>1.0.1</version>
 <longdesc lang="en">
 This script manages Lustre Targets (MGT, MDT, OST).
 The script is able to mount/umount Lustre Targets.
@@ -76,6 +77,14 @@ The mount point where the Lustre target will be mounted.
 <content type="string" default="" />
 </parameter>
 
+<parameter name="mountoptions" unique="1" required="0">
+<longdesc lang="en">
+Any additional mount options for the Lustre target. (eg: "-o skpath=/path/to/keys")
+</longdesc>
+<shortdesc lang="en">Mount options for Lustre target</shortdesc>
+<content type="string" default="" />
+</parameter>
+
 </parameters>
 
 <actions>
@@ -98,7 +107,9 @@ lustre_is_mounted () {
     # Verify if this is consistent, check pointpoint and filesystem
     # against source (i.e. device)
     local dev=$(findmnt -t lustre -ln -o SOURCE -T $(realpath "$OCF_RESKEY_mountpoint"))
-    [ "$dev" == "$OCF_RESKEY_target" ]
+
+    [ -n "$dev" ] &&
+    [ "$dev" == "$OCF_RESKEY_target" -o "$dev" == $(realpath "$OCF_RESKEY_target") ]
 }
 
 lustre_monitor () {
@@ -119,26 +130,36 @@ lustre_mount () {
     if ! lustre_is_mounted; then
        ocf_log info "Starting to mount $OCF_RESKEY_target"
 
-       if mount -t lustre $OCF_RESKEY_target $OCF_RESKEY_mountpoint ; then
+       output=$(mount -t lustre $OCF_RESKEY_mountoptions $OCF_RESKEY_target $OCF_RESKEY_mountpoint 2>&1)
+       rc=$?
+       if [ $rc -eq 0 ]; then
            ocf_log info "$OCF_RESKEY_target mounted successfully"
+           [ -n "$output" ] && ocf_log info "$output"
            return $OCF_SUCCESS
        fi
-       ocf_log err "$OCF_RESKEY_volume mount failed"
+       ocf_log err "$OCF_RESKEY_target mount failed, rc=$rc"
+       ocf_log err "$output"
        return $OCF_ERR_GENERIC
     fi
+    return $OCF_SUCCESS
 }
 
 lustre_umount () {
     if lustre_is_mounted; then
        ocf_log info "Starting to unmount $OCF_RESKEY_target"
 
-       if umount $OCF_RESKEY_mountpoint; then
+       output=$(umount $OCF_RESKEY_mountpoint 2>&1)
+       rc=$?
+       if [ $rc -eq 0 ]; then
            ocf_log info "$OCF_RESKEY_target unmounted successfully"
+           [ -n "$output" ] && ocf_log info "$output"
            return $OCF_SUCCESS
        fi
-       ocf_log err "$OCF_RESKEY_target unmount failed"
+       ocf_log err "$OCF_RESKEY_target unmount failed, rc=$rc"
+       ocf_log err "$output"
        return $OCF_ERR_GENERIC
     fi
+    return $OCF_SUCCESS
 }
 
 all_start () {
@@ -162,7 +183,7 @@ all_stop () {
 }
 
 validate () {
-    if [ ! -d "$OCF_RESKEY_mountpoint" ]; then
+    if [ ! -d "$(realpath $OCF_RESKEY_mountpoint)" ]; then
        ocf_log err "$OCF_RESKEY_mountpoint can not be found"
        return $OCF_ERR_INSTALLED
     fi