Bug 1006077 - targetcli fails when attempt to list non standard block device partitions
Summary: targetcli fails when attempt to list non standard block device partitions
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-rtslib
Version: 19
Hardware: x86_64
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Andy Grover
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-09-10 00:29 UTC by Dave Jiang
Modified: 2013-10-03 01:15 UTC (History)
2 users (show)

Fixed In Version: python-rtslib-2.1.fb40-1.fc19
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-09-30 00:31:28 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Dave Jiang 2013-09-10 00:29:48 UTC
Description of problem:
When using a block partition that is non-standard such as NVME device, targetcli fails to locate the sysfs size file. 

Version-Release number of selected component (if applicable):
targetcli-2.1.fb26-1.fc19.noarch

How reproducible:

Steps to Reproduce:
1. run targetcli
2. cd /backstores/block
3. create nvme0 /dev/nvme0n1p5
4. ls

Actual results:
/backstores/block> create nvme0 /dev/nvme0n1p5
Created block storage object nvme0 using /dev/nvme0n1p5.
/backstores/block> ls
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 990, in run_interactive
    self._cli_loop()
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 813, in _cli_loop
    self.run_cmdline(cmdline)
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 934, in run_cmdline
    self._execute_command(path, command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell/shell.py", line 909, in _execute_command
    result = target.execute_command(command, pparams, kparams)
  File "/usr/lib/python2.7/site-packages/targetcli/ui_node.py", line 87, in execute_command
    pparams, kparams)
  File "/usr/lib/python2.7/site-packages/configshell/node.py", line 1417, in execute_command
    result = method(*pparams, **kparams)
  File "/usr/lib/python2.7/site-packages/configshell/node.py", line 714, in ui_command_ls
    tree = self._render_tree(target, depth=depth)
  File "/usr/lib/python2.7/site-packages/configshell/node.py", line 865, in _render_tree
    + self._render_tree(children[i], margin, depth)
  File "/usr/lib/python2.7/site-packages/configshell/node.py", line 769, in _render_tree
    (description, is_healthy) = root.summary()
  File "/usr/lib/python2.7/site-packages/targetcli/ui_backstore.py", line 423, in summary
    return ("%s (%s) %s%s %s" % (so.udev_path, bytes_to_human(so.size),
  File "/usr/lib/python2.7/site-packages/rtslib/tcm.py", line 707, in _get_size
    return get_blockdev_size(self._parse_info('device')) * int(self._parse_info('SectorSize'))
  File "/usr/lib/python2.7/site-packages/rtslib/utils.py", line 124, in get_blockdev_size
    return int(fread("/sys/block/%s/%s/size" % (m.groups()[0], m.group())))
  File "/usr/lib/python2.7/site-packages/rtslib/utils.py", line 88, in fread
    with open(path, 'r') as file_fd:
IOError: [Errno 2] No such file or directory: '/sys/block/p/p5/size'

Expected results:
/backstores/block> ls
o- block ................................................. [Storage Objects: 1]
  o- nvme0 ...................... [/dev/nvme0n1p5 (2.0GiB) write-thru activated]

Additional info:
Essentially in /usr/lib/python2.7/site-packages/rtslib/utils.py:122 where it does the regular expression search match it is not able to handle anything besides generic block devices such as /dev/sdN and /dev/hdN. A non typical block device naming such as NVME breaks that search pattern. It should end up reading:
/sys/block/nvme0n1/nvme0n1p5/size and not /sys/block/p/p5/size.

Comment 1 Fedora Update System 2013-09-10 17:44:51 UTC
python-rtslib-2.1.fb38-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb38-1.fc19

Comment 2 Fedora Update System 2013-09-10 17:45:01 UTC
python-rtslib-2.1.fb38-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb38-1.fc20

Comment 3 Fedora Update System 2013-09-10 17:45:10 UTC
python-rtslib-2.1.fb38-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb38-1.fc18

Comment 4 Fedora Update System 2013-09-11 01:59:54 UTC
Package python-rtslib-2.1.fb38-1.fc18:
* should fix your issue,
* was pushed to the Fedora 18 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-rtslib-2.1.fb38-1.fc18'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-16355/python-rtslib-2.1.fb38-1.fc18
then log in and leave karma (feedback).

Comment 5 Dave Jiang 2013-09-11 17:01:02 UTC
I tested and it's fixed. Thanks!

Comment 6 Fedora Update System 2013-09-11 18:30:47 UTC
python-rtslib-2.1.fb39-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb39-1.fc19

Comment 7 Fedora Update System 2013-09-11 18:31:04 UTC
python-rtslib-2.1.fb39-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb39-1.fc18

Comment 8 Fedora Update System 2013-09-11 18:31:13 UTC
python-rtslib-2.1.fb39-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb39-1.fc20

Comment 9 Fedora Update System 2013-09-23 22:08:07 UTC
python-rtslib-2.1.fb40-1.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb40-1.fc19

Comment 10 Fedora Update System 2013-09-23 22:08:17 UTC
python-rtslib-2.1.fb40-1.fc18 has been submitted as an update for Fedora 18.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb40-1.fc18

Comment 11 Fedora Update System 2013-09-23 22:08:26 UTC
python-rtslib-2.1.fb40-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/python-rtslib-2.1.fb40-1.fc20

Comment 12 Fedora Update System 2013-09-30 00:31:28 UTC
python-rtslib-2.1.fb40-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2013-10-03 01:08:25 UTC
python-rtslib-2.1.fb40-1.fc18 has been pushed to the Fedora 18 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 14 Fedora Update System 2013-10-03 01:15:39 UTC
python-rtslib-2.1.fb40-1.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.