From: Anna Schumaker <anna@kernel.org>
To: linux-nfs@vger.kernel.org, steved@redhat.com
Cc: anna@kernel.org
Subject: [PATCH nfs-utils v3 6/7] rpcctl: Add missing docstrings to the XprtSwitch class
Date: Wed, 15 Jan 2025 15:29:55 -0500 [thread overview]
Message-ID: <20250115202957.113352-7-anna@kernel.org> (raw)
In-Reply-To: <20250115202957.113352-1-anna@kernel.org>
From: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
---
tools/rpcctl/rpcctl.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index b8808787b51d..adeb26d51f0e 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -177,7 +177,10 @@ class Xprt:
class XprtSwitch:
+ """Represents a group of xprt connections."""
+
def __init__(self, path, sep=":"):
+ """Read in xprt switch information from sysfs."""
self.path = path
self.name = path.stem
self.info = read_info_file(path / "xprt_switch_info")
@@ -186,9 +189,11 @@ class XprtSwitch:
self.sep = sep
def __lt__(self, rhs):
+ """Compare the name of two xprt switch instances."""
return self.name < rhs.name
def __str__(self):
+ """Return a string representation of an xprt switch."""
switch = f"{self.name}{self.sep} " \
f"xprts {self.info['num_xprts']}, " \
f"active {self.info['num_active']}, " \
@@ -197,6 +202,7 @@ class XprtSwitch:
return "\n".join([switch] + xprts)
def add_command(subparser):
+ """Add parser options for the `rpcctl switch` command."""
parser = subparser.add_parser("switch",
help="Commands for xprt switches")
parser.set_defaults(func=XprtSwitch.show, switch=None)
@@ -219,16 +225,19 @@ class XprtSwitch:
dstaddr.set_defaults(func=XprtSwitch.set_property, property="dstaddr")
def get_by_name(name):
+ """Find a (sorted) list of XprtSwitches matching the given name."""
xprt_switches = sunrpc / "xprt-switches"
if name:
return [XprtSwitch(xprt_switches / name)]
return [XprtSwitch(f) for f in sorted(xprt_switches.iterdir())]
def show(args):
+ """Handle the `rpcctl switch show` command."""
for switch in XprtSwitch.get_by_name(args.switch):
print(switch)
def set_property(args):
+ """Handle the `rpcctl switch set` command."""
for switch in XprtSwitch.get_by_name(args.switch[0]):
resolved = socket.gethostbyname(args.newaddr[0])
for xprt in switch.xprts:
--
2.48.1
next prev parent reply other threads:[~2025-01-15 20:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 20:29 [PATCH nfs-utils v3 0/7] rpcctl: Flake8 cleanups Anna Schumaker
2025-01-15 20:29 ` [PATCH nfs-utils v3 1/7] rpcctl: Fix flake8 whitespace errors Anna Schumaker
2025-01-15 20:29 ` [PATCH nfs-utils v3 2/7] rpcctl: Fix flake8 line-too-long errors Anna Schumaker
2025-01-15 20:29 ` [PATCH nfs-utils v3 3/7] rpcctl: Fix flake8 bare exception error Anna Schumaker
2025-01-15 20:29 ` [PATCH nfs-utils v3 4/7] rpcctl: Fix flake8 ambiguous-variable-name error Anna Schumaker
2025-01-15 20:29 ` [PATCH nfs-utils v3 5/7] rpcctl: Add missing docstrings to the Xprt class Anna Schumaker
2025-01-15 20:29 ` Anna Schumaker [this message]
2025-01-15 20:29 ` [PATCH nfs-utils v3 7/7] rpcctl: Add remaining missing docstrings Anna Schumaker
2025-01-25 16:33 ` [PATCH nfs-utils v3 0/7] rpcctl: Flake8 cleanups Steve Dickson
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=20250115202957.113352-7-anna@kernel.org \
--to=anna@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox