Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Asleson <tasleson@redhat.com>
To: linux-nvme@lists.infradead.org
Subject: [PATCH] nvmetcli: Correct xrange usage for py3
Date: Wed,  1 Apr 2020 14:13:16 -0500	[thread overview]
Message-ID: <20200401191316.54355-1-tasleson@redhat.com> (raw)

If you are in a namespace and simply do a 'create' without specifying
a value you will get:

/subsystems/n...f8/namespaces> create
name 'xrange' is not defined
subsystems/n...f8/namespaces>

This is because xrange is not defined in python3 as python3 changed
it to range.  As the code is already using six use six.move.xrange
which works for both python2 & python3.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
---
 nvmet/nvme.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/nvmet/nvme.py b/nvmet/nvme.py
index db8a03c..83fd75b 100644
--- a/nvmet/nvme.py
+++ b/nvmet/nvme.py
@@ -23,7 +23,7 @@ import stat
 import uuid
 import json
 from glob import iglob as glob
-from six import iteritems
+from six import iteritems, moves
 
 DEFAULT_SAVE_FILE = '/etc/nvmet/config.json'
 
@@ -556,7 +556,7 @@ class Namespace(CFSNode):
                 raise CFSError("Need NSID for lookup")
 
             nsids = [n.nsid for n in subsystem.namespaces]
-            for index in xrange(1, self.MAX_NSID + 1):
+            for index in moves.xrange(1, self.MAX_NSID + 1):
                 if index not in nsids:
                     nsid = index
                     break
@@ -816,7 +816,7 @@ class ANAGroup(CFSNode):
                 raise CFSError("Need grpid for lookup")
 
             grpids = [n.grpid for n in port.ana_groups]
-            for index in xrange(2, self.MAX_GRPID + 1):
+            for index in moves.xrange(2, self.MAX_GRPID + 1):
                 if index not in grpids:
                     grpid = index
                     break
-- 
2.25.1


_______________________________________________
linux-nvme mailing list
linux-nvme@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-nvme

             reply	other threads:[~2020-04-01 19:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-01 19:13 Tony Asleson [this message]
2020-04-01 20:35 ` [PATCH] nvmetcli: Correct xrange usage for py3 Sagi Grimberg
2020-04-03  6:55 ` Christoph Hellwig

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=20200401191316.54355-1-tasleson@redhat.com \
    --to=tasleson@redhat.com \
    --cc=linux-nvme@lists.infradead.org \
    /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