All of lore.kernel.org
 help / color / mirror / Atom feed
From: schumaker.anna@gmail.com
To: steved@redhat.com, linux-nfs@vger.kernel.org
Cc: Anna.Schumaker@Netapp.com
Subject: [PATCH v7 6/9] rpcctl: Add a command for changing xprt switch dstaddrs
Date: Thu, 27 Jan 2022 14:49:49 -0500	[thread overview]
Message-ID: <20220127194952.63033-7-Anna.Schumaker@Netapp.com> (raw)
In-Reply-To: <20220127194952.63033-1-Anna.Schumaker@Netapp.com>

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>
---
 tools/rpcctl/rpcctl.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index c481f96333f9..9404b975e33d 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):
-- 
2.35.0


  parent reply	other threads:[~2022-01-27 19:50 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-27 19:49 [PATCH v7 0/9] Add a tool for using the new sysfs files schumaker.anna
2022-01-27 19:49 ` [PATCH v7 1/9] rpcctl: Add a rpcctl.py tool schumaker.anna
2022-02-01 15:57   ` David Wysochanski
2022-02-02 15:33     ` Steve Dickson
2022-01-27 19:49 ` [PATCH v7 2/9] rpcctl: Add a command for printing xprt switch information schumaker.anna
2022-01-27 19:49 ` [PATCH v7 3/9] rpcctl: Add a command for printing individual xprts schumaker.anna
2022-01-27 19:49 ` [PATCH v7 4/9] rpcctl: Add a command for printing rpc client information schumaker.anna
2022-01-27 19:49 ` [PATCH v7 5/9] rpcctl: Add a command for changing xprt dstaddr schumaker.anna
2022-01-27 19:49 ` schumaker.anna [this message]
2022-01-27 19:49 ` [PATCH v7 7/9] rpcctl: Add a command for changing xprt state schumaker.anna
2022-01-27 19:49 ` [PATCH v7 8/9] rpcctl: Add a man page schumaker.anna
2022-02-07 19:58   ` Steve Dickson
2022-02-07 20:32     ` Anna Schumaker
2022-01-27 19:49 ` [PATCH v7 9/9] rpcctl: Add installation to the Makefile schumaker.anna

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220127194952.63033-7-Anna.Schumaker@Netapp.com \
    --to=schumaker.anna@gmail.com \
    --cc=Anna.Schumaker@Netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.