linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online
@ 2022-05-19 15:47 Anna Schumaker
  2022-05-19 15:47 ` [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt Anna Schumaker
  2022-05-26 17:34 ` [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Steve Dickson
  0 siblings, 2 replies; 4+ messages in thread
From: Anna Schumaker @ 2022-05-19 15:47 UTC (permalink / raw)
  To: linux-nfs, steved; +Cc: anna

From: Anna Schumaker <Anna.Schumaker@Netapp.com>

Otherwise the tool will tell us:
    'Namespace' object has no attribute 'set_state'

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
 tools/rpcctl/rpcctl.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
index b8df556b682c..2a69eacd3103 100755
--- a/tools/rpcctl/rpcctl.py
+++ b/tools/rpcctl/rpcctl.py
@@ -142,7 +142,7 @@ class Xprt:
                 xprt.set_state("offline")
                 xprt.set_state("remove")
             else:
-                args.set_state(args.property)
+                xprt.set_state(args.property)
         print(xprt)
 
 
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt
  2022-05-19 15:47 [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Anna Schumaker
@ 2022-05-19 15:47 ` Anna Schumaker
  2022-05-26 17:34   ` Steve Dickson
  2022-05-26 17:34 ` [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Steve Dickson
  1 sibling, 1 reply; 4+ messages in thread
From: Anna Schumaker @ 2022-05-19 15:47 UTC (permalink / raw)
  To: linux-nfs, steved; +Cc: anna

From: Anna Schumaker <Anna.Schumaker@Netapp.com>

'main' xprts cannot be set offline or removed, so print a helpful error
message in this case instead of a cryptic 'invalid argument' message.

Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
---
 tools/rpcctl/rpcctl.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online
  2022-05-19 15:47 [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Anna Schumaker
  2022-05-19 15:47 ` [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt Anna Schumaker
@ 2022-05-26 17:34 ` Steve Dickson
  1 sibling, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2022-05-26 17:34 UTC (permalink / raw)
  To: Anna Schumaker, linux-nfs



On 5/19/22 11:47 AM, Anna Schumaker wrote:
> From: Anna Schumaker <Anna.Schumaker@Netapp.com>
> 
> Otherwise the tool will tell us:
>      'Namespace' object has no attribute 'set_state'
> 
> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Committed... (tag: nfs-utils-2-6-2-rc5)

steved.
> ---
>   tools/rpcctl/rpcctl.py | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/rpcctl/rpcctl.py b/tools/rpcctl/rpcctl.py
> index b8df556b682c..2a69eacd3103 100755
> --- a/tools/rpcctl/rpcctl.py
> +++ b/tools/rpcctl/rpcctl.py
> @@ -142,7 +142,7 @@ class Xprt:
>                   xprt.set_state("offline")
>                   xprt.set_state("remove")
>               else:
> -                args.set_state(args.property)
> +                xprt.set_state(args.property)
>           print(xprt)
>   
>   


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt
  2022-05-19 15:47 ` [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt Anna Schumaker
@ 2022-05-26 17:34   ` Steve Dickson
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Dickson @ 2022-05-26 17:34 UTC (permalink / raw)
  To: Anna Schumaker, linux-nfs



On 5/19/22 11:47 AM, Anna Schumaker wrote:
> From: Anna Schumaker <Anna.Schumaker@Netapp.com>
> 
> 'main' xprts cannot be set offline or removed, so print a helpful error
> message in this case instead of a cryptic 'invalid argument' message.
> 
> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Committed... (tag: nfs-utils-2-6-2-rc5)

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-26 17:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-19 15:47 [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Anna Schumaker
2022-05-19 15:47 ` [PATCH v2 2/2] rpcctl: Print a message if the user tries to modify a main xprt Anna Schumaker
2022-05-26 17:34   ` Steve Dickson
2022-05-26 17:34 ` [PATCH v2 1/2] rpcctl: Use the correct function for setting xprts offline and online Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).