diff mbox series

[v6,6/9] rpcctl: Add a command for changing xprt switch dstaddrs

Message ID 20220125190946.23586-7-Anna.Schumaker@Netapp.com (mailing list archive)
State New, archived
Headers show
Series Add a tool for using the new sysfs files | expand

Commit Message

Anna Schumaker Jan. 25, 2022, 7:09 p.m. UTC
From: Anna Schumaker <Anna.Schumaker@Netapp.com>

This is basically the same as for xprts, but it iterates through all
xprts attached to the switch to apply the new address.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
v6: Continue single file squash
---
 tools/rpcctl/rpcctl.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index a5f83c46298f..0c6c9d0f006c 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -143,6 +143,12 @@  class XprtSwitch:
         parser.add_argument("--id", metavar="ID", nargs=1, type=int, help="Id of a specific xprt-switch to show")
         parser.set_defaults(func=XprtSwitch.list_all)
 
+        subparser = parser.add_subparsers()
+        parser = subparser.add_parser("set", help="Set an xprt switch property")
+        parser.add_argument("--id", metavar="ID", nargs=1, type=int, required=True, help="Id of an xprt-switch to modify")
+        parser.add_argument("--dstaddr", metavar="dstaddr", nargs=1, type=str, help="New dstaddr to set")
+        parser.set_defaults(func=XprtSwitch.set_property)
+
     def list_all(args):
         switches = [ XprtSwitch(f) for f in (sunrpc / "xprt-switches").iterdir() ]
         switches.sort()
@@ -150,6 +156,16 @@  class XprtSwitch:
             if args.id == None or xs.id == args.id[0]:
                 print(xs)
 
+    def set_property(args):
+        switch = XprtSwitch(sunrpc / "xprt-switches" / f"switch-{args.id[0]}")
+        try:
+            for xprt in switch.xprts:
+                if args.dstaddr != None:
+                    xprt.set_dstaddr(args.dstaddr[0])
+            print(switch)
+        except Exception as e:
+            print(e)
+
 
 class RpcClient:
     def __init__(self, path):