Blame SOURCES/nfs-utils-2.5.4-rpcctl-xprt.patch

ee8f10
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
ee8f10
index b8df556b..d2110ad6 100755
ee8f10
--- a/tools/rpcctl/rpcctl.py
ee8f10
+++ b/tools/rpcctl/rpcctl.py
ee8f10
@@ -90,10 +90,18 @@ class Xprt:
ee8f10
         self.dstaddr = write_addr_file(self.path / "dstaddr", newaddr)
ee8f10
 
ee8f10
     def set_state(self, state):
ee8f10
+        if self.info.get("main_xprt"):
ee8f10
+            raise Exception(f"Main xprts cannot be set {state}")
ee8f10
         with open(self.path / "xprt_state", 'w') as f:
ee8f10
             f.write(state)
ee8f10
         self.read_state()
ee8f10
 
ee8f10
+    def remove(self):
ee8f10
+        if self.info.get("main_xprt"):
ee8f10
+            raise Exception("Main xprts cannot be removed")
ee8f10
+        self.set_state("offline")
ee8f10
+        self.set_state("remove")
ee8f10
+
ee8f10
     def add_command(subparser):
ee8f10
         parser = subparser.add_parser("xprt", help="Commands for individual xprts")
ee8f10
         parser.set_defaults(func=Xprt.show, xprt=None)
ee8f10
@@ -139,10 +147,9 @@ class Xprt:
ee8f10
             if args.property == "dstaddr":
ee8f10
                 xprt.set_dstaddr(socket.gethostbyname(args.newaddr[0]))
ee8f10
             elif args.property == "remove":
ee8f10
-                xprt.set_state("offline")
ee8f10
-                xprt.set_state("remove")
ee8f10
+                xprt.remove()
ee8f10
             else:
ee8f10
-                args.set_state(args.property)
ee8f10
+                xprt.set_state(args.property)
ee8f10
         print(xprt)
ee8f10
 
ee8f10