From: Tony Asleson Date: Wed, 1 Apr 2020 19:13:16 +0000 (-0500) Subject: nvmetcli: Correct xrange usage for py3 X-Git-Tag: v0.8~6 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9da40b0433b8338f82c2c910b1057e1e1061b9a0;p=users%2Fhch%2Fnvmetcli.git nvmetcli: Correct xrange usage for py3 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 Reviewed-by: Sagi Grimberg Signed-off-by: Christoph Hellwig --- 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