diff options
author | Anna Schumaker <Anna.Schumaker@Netapp.com> | 2022-05-26 13:05:51 -0400 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2022-05-26 13:11:57 -0400 |
commit | 6a0a107e1ded470af827e1d416515c77b214a12e (patch) | |
tree | bc0ce64a0e0580ffa73374771b68dd569e05b772 | |
parent | 1393b549eb80761d5f8c6b2c9ed711fb55b507d1 (diff) | |
download | nfs-utils-6a0a107e1ded470af827e1d416515c77b214a12e.tar.gz |
rpcctl: Print a message if the user tries to modify a main xprtnfs-utils-2-6-2-rc5
'main' xprts cannot be set offline or removed, so print a helpful error
message in this case instead of a cryptic 'invalid argument' message.
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rwxr-xr-x | tools/rpcctl/rpcctl.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py index 2a69eac..d2110ad 100755 --- a/tools/rpcctl/rpcctl.py +++ b/tools/rpcctl/rpcctl.py @@ -90,10 +90,18 @@ class Xprt: self.dstaddr = write_addr_file(self.path / "dstaddr", newaddr) def set_state(self, state): + if self.info.get("main_xprt"): + raise Exception(f"Main xprts cannot be set {state}") with open(self.path / "xprt_state", 'w') as f: f.write(state) self.read_state() + def remove(self): + if self.info.get("main_xprt"): + raise Exception("Main xprts cannot be removed") + self.set_state("offline") + self.set_state("remove") + def add_command(subparser): parser = subparser.add_parser("xprt", help="Commands for individual xprts") parser.set_defaults(func=Xprt.show, xprt=None) @@ -139,8 +147,7 @@ class Xprt: if args.property == "dstaddr": xprt.set_dstaddr(socket.gethostbyname(args.newaddr[0])) elif args.property == "remove": - xprt.set_state("offline") - xprt.set_state("remove") + xprt.remove() else: xprt.set_state(args.property) print(xprt) |