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

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