diff options
author | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2022-02-22 12:12:15 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2022-02-23 11:45:51 -0500 |
commit | f857fbca48ecf9fa5aac797df7393d096e71bb2a (patch) | |
tree | 69839437076d3bd5f2a00fe8901ccc11c3ead4c2 | |
parent | 9abd3b4b57155dfdfd6895e6086ef550ee56fc49 (diff) | |
download | nfs-utils-f857fbca48ecf9fa5aac797df7393d096e71bb2a.tar.gz |
rpcctl: Add a rpcctl.py tool
This will be used to print and manipulate the sunrpc sysfs directory
files. Running without arguments prints both usage information and the
location of the sunrpc sysfs directory.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rwxr-xr-x | tools/rpcctl/rpcctl.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py new file mode 100755 index 0000000..9737ac4 --- /dev/null +++ b/tools/rpcctl/rpcctl.py @@ -0,0 +1,25 @@ +#!/usr/bin/python3 +import argparse +import pathlib +import sys + +with open("/proc/mounts", 'r') as f: + mount = [ line.split()[1] for line in f if "sysfs" in line ] + if len(mount) == 0: + print("ERROR: sysfs is not mounted") + sys.exit(1) + +sunrpc = pathlib.Path(mount[0]) / "kernel" / "sunrpc" +if not sunrpc.is_dir(): + print("ERROR: sysfs does not have sunrpc directory") + sys.exit(1) + +parser = argparse.ArgumentParser() + +def show_small_help(args): + parser.print_usage() + print("sunrpc dir:", sunrpc) +parser.set_defaults(func=show_small_help) + +args = parser.parse_args() +args.func(args) |