nfs-utils/SOURCES/nfs-utils-2.5.4-rpcctl-xprt.patch
2022-11-15 11:52:17 +00:00

37 lines
1.3 KiB
Diff

diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index b8df556b..d2110ad6 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,10 +147,9 @@ 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:
- args.set_state(args.property)
+ xprt.set_state(args.property)
print(xprt)