Hannes Reinecke [Fri, 5 Feb 2021 09:56:36 +0000 (10:56 +0100)]
nvmetcli: fixup ana groupid setting for namespaces
The ANA group of a namespace is displayed, but can't be set.
So add a new attribute group 'ana' to the namespace such that
it can be set via 'set ana grpid'.
Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Wed, 1 Apr 2020 19:13:16 +0000 (14:13 -0500)]
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 <tasleson@redhat.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Thu, 2 Apr 2020 15:54:43 +0000 (10:54 -0500)]
nvmetcli: Allow different devices for make test
The test_nvmet.py by default uses /dev/ram0 and /dev/ram1 for 2 of the
unit tests. Add env. variable to allow user to specify different devices
or files. Additionally, skip these unit tests that require devices/files
if they are not present. Update README too.
$ sudo make test
......s...s.
----------------------------------------------------------------------
Ran 12 tests in 0.043s
OK (skipped=2)
Name Stmts Miss Cover
-----------------------------------------
nvmet/__init__.py 1 0 100%
nvmet/nvme.py 517 237 54%
nvmet/test_nvmet.py 276 63 77%
-----------------------------------------
TOTAL 794 300 62%
$ sudo NVMET_TEST_DEVICES="/dev/sdc,/dev/sdd" make test
............
----------------------------------------------------------------------
Ran 12 tests in 0.124s
OK
Name Stmts Miss Cover
-----------------------------------------
nvmet/__init__.py 1 0 100%
nvmet/nvme.py 517 100 81%
nvmet/test_nvmet.py 276 4 99%
-----------------------------------------
TOTAL 794 104 87%
Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Thu, 26 Mar 2020 18:07:50 +0000 (13:07 -0500)]
nvmetcli: Report save name correctly
When a user simply does 'nvmetcli restore' without
specifying a file name the default is used. However, if the
restore fails you end up with the error message:
Error processing config file at None, error [Errno 1] Operation not
permitted: '/sys/kernel/config/nvmet/ports/0/ana_groups/1', exiting
Correct file name if None in error path.
Error processing config file at /etc/nvmet/config.json, error \
[Errno 1] Operation not permitted: \
'/sys/kernel/config/nvmet/ports/1/ana_groups/1', exiting
Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Thu, 26 Mar 2020 18:07:49 +0000 (13:07 -0500)]
test_nvmet.py: test_invalid_input fails for py3
When you run 'make test' using python 3 the unit test
test_invalid_input fails with:
Traceback (most recent call last):
File "/someuser/projects/nvmetcli/nvmet/test_nvmet.py", line 395, in
test_invalid_input
for i in range(l))
File "/someuser/projects/nvmetcli/nvmet/test_nvmet.py", line 395, in
<genexpr>
for i in range(l))
AttributeError: module 'string' has no attribute 'lowercase'
Python 3 does not have 'string.lowercase' ref.
https://docs.python.org/3/library/string.html
Python 2 does ref.
https://docs.python.org/2/library/string.html
Both have "string.ascii_lowercase" so lets leverage that to
support both.
Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Thu, 26 Mar 2020 18:07:47 +0000 (13:07 -0500)]
nvme.py: Sync the containing directory
It's apparent that some thought went into making sure the config
file makes it atomically to the fs. However, one thing is missing
which is doing a fsync on the containing directory of the config file.
See: https://lwn.net/Articles/457667/
Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tony Asleson [Thu, 26 Mar 2020 18:07:45 +0000 (13:07 -0500)]
nvmetcli: Improve IOError handling on restore
Not all IOErrors are caused by specifying a missing configuration
file. When the file is present, dump the error exception text too,
so the user has a better idea what is wrong.
Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Steve Wise [Mon, 9 Jul 2018 17:00:26 +0000 (10:00 -0700)]
nvmetcli: support inline_data_size port parameter
The port parameter attribute param_inline_data_size allows adjusting
the amount of inline data that can be included in a write IO. Setting
it to < 0 (or not setting it at all) allows the transport to choose a
reasonable default, which will be 0 if that transport does not support
inline. Setting it to 0 disables the transport from using inline_data.
And setting it to > 0 configures that port/transport to use that inline
data size, in bytes, if the transport supports it.
Signed-off-by: Steve Wise <swise@opengridcomputing.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
The status attribute reflects if any subsystems are bound and can accept
existing connections. The state attribute reflects the physical state of
the port. Also colorize UI if port state is down.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Christoph Hellwig <hch@lst.de>
nvmetcli defines a status method for the UIPortNode class but there is
no corresponding 'enable' file in configfs so typing in status will
always result in nvmetcli printing disbaled if one types 'status' in
the port node:
/> cd ports/1/
/ports/1> status
Status for /ports/1: disabled
/ports/1>
There are two possible ways for fixing this issue, provide a configfs
file to enable/disable the port node in the kernel or delete the
method in nvmetcli. Having a configfs file in the kernel is pointless,
as ports get enabled when symlinked to a namespace so zap the pointless status
method in user-space.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Reported-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
nvmetcli: Install nvmetcli in /usr/sbin with setup.py
According to the README, one can install nvmetcli through setup.py.
When one tries this though, the nvmetcli isn't configured in system's
$PATH.
Adding nvmetcli to scripts argument in setup call does half of the job.
Then, in order to install it in the correct location in a maintanable
way it's introduced setup.cfg file which contains 'install_scripts'
parameter for 'install' command set to /usr/sbin.
Nothing changes on the .deb package creation, the .rpm package process
in the other hand was made simpler by lines that are now done by
setup.py + setup.cfg settings.
Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
It's not possible to create or list a Referral under Port entity,
because Referral class is not imported and thus it fails:
/ports/1/referrals> ls
returning "'module' object has no attribute 'Referral'".
This is caused by changes introduced in: a21ebd54f0 ("nvmetcli: Fix nvmet import").
This patch also fixes the attribute type helper expected for Referral's
portid attribute. It was 'int', causing the system to show error
messages like:
"'UIReferralNode' object has no attribute 'ui_type_int'".
The correct type is 'number'.
Reviewed-by: Guilherme G. Piccoli<gpiccoli@linux.vnet.ibm.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com> Tested-by: Sagi Grimberg <sagi@grimberg.m> Signed-off-by: Mauro S. M. Rodrigues <maurosr@linux.vnet.ibm.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Jay Freyensee [Thu, 8 Sep 2016 19:14:24 +0000 (12:14 -0700)]
nvmetcli: README description of discovery
Some blurbs on discovery and the connection
between using nvmetcli to set up an NVMe target and
what gets seen by an NVMe Host when accessing
the discovery controller.
Signed-off-by: Jay Freyensee <james_p_freyensee@linux.intel.com>