Blame SOURCES/0010-nvmetcli-Correct-xrange-usage-for-py3.patch

76c28c
From 9da40b0433b8338f82c2c910b1057e1e1061b9a0 Mon Sep 17 00:00:00 2001
76c28c
From: Tony Asleson <tasleson@redhat.com>
76c28c
Date: Wed, 1 Apr 2020 14:13:16 -0500
76c28c
Subject: [PATCH 10/12] nvmetcli: Correct xrange usage for py3
76c28c
76c28c
If you are in a namespace and simply do a 'create' without specifying
76c28c
a value you will get:
76c28c
76c28c
/subsystems/n...f8/namespaces> create
76c28c
name 'xrange' is not defined
76c28c
subsystems/n...f8/namespaces>
76c28c
76c28c
This is because xrange is not defined in python3 as python3 changed
76c28c
it to range.  As the code is already using six use six.move.xrange
76c28c
which works for both python2 & python3.
76c28c
76c28c
Signed-off-by: Tony Asleson <tasleson@redhat.com>
76c28c
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
76c28c
Signed-off-by: Christoph Hellwig <hch@lst.de>
76c28c
---
76c28c
 nvmet/nvme.py | 6 +++---
76c28c
 1 file changed, 3 insertions(+), 3 deletions(-)
76c28c
76c28c
diff --git a/nvmet/nvme.py b/nvmet/nvme.py
76c28c
index db8a03c..83fd75b 100644
76c28c
--- a/nvmet/nvme.py
76c28c
+++ b/nvmet/nvme.py
76c28c
@@ -23,7 +23,7 @@ import stat
76c28c
 import uuid
76c28c
 import json
76c28c
 from glob import iglob as glob
76c28c
-from six import iteritems
76c28c
+from six import iteritems, moves
76c28c
 
76c28c
 DEFAULT_SAVE_FILE = '/etc/nvmet/config.json'
76c28c
 
76c28c
@@ -556,7 +556,7 @@ class Namespace(CFSNode):
76c28c
                 raise CFSError("Need NSID for lookup")
76c28c
 
76c28c
             nsids = [n.nsid for n in subsystem.namespaces]
76c28c
-            for index in xrange(1, self.MAX_NSID + 1):
76c28c
+            for index in moves.xrange(1, self.MAX_NSID + 1):
76c28c
                 if index not in nsids:
76c28c
                     nsid = index
76c28c
                     break
76c28c
@@ -816,7 +816,7 @@ class ANAGroup(CFSNode):
76c28c
                 raise CFSError("Need grpid for lookup")
76c28c
 
76c28c
             grpids = [n.grpid for n in port.ana_groups]
76c28c
-            for index in xrange(2, self.MAX_GRPID + 1):
76c28c
+            for index in moves.xrange(2, self.MAX_GRPID + 1):
76c28c
                 if index not in grpids:
76c28c
                     grpid = index
76c28c
                     break
76c28c
-- 
76c28c
2.29.2
76c28c