Datera / rtslib

The Linux SCSI Target API
http://linux-iscsi.org
Apache License 2.0
19 stars 17 forks source link

rtslib: AttributeError: 'list' object has no attribute 'asList' #13

Open rickysarraf opened 8 years ago

rickysarraf commented 8 years ago

Please see Debian Bug https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=824566 for more details.

With newer pyparsing, rtslib fails to load the config. The proposed fix makes it work again.

Fix

        value = tokin[0].asDict()
        ref_path = value.get('ref_path')
        if ref_path is not None:
            ref_path = " ".join(ref_path.asList())

To

        value = tokin[0].asDict()
        ref_path = value.get('ref_path')
        if ref_path is not None:
            ref_path = " ".join(ref_path)

Actual bug exception without the patch.

root@debian-iscsi-target:~# python
Python 2.7.11+ (default, May  9 2016, 15:54:33) 
[GCC 5.3.1 20160429] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from rtslib import Config
>>> config = Config()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 133, in __init__
    self._load_policy()
  File "/usr/lib/python2.7/dist-packages/rtslib/config.py", line 144, in _load_policy
    parse_tree = self._policy_parser.parse_file(filepath)
  File "/usr/lib/python2.7/dist-packages/rtslib/config_parser.py", line 144, in parse_file
    return self._parser.parseFile(filepath, parseAll=True).asList()
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1555, in parseFile
    return self.parseString(file_contents, parseAll)
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1162, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2888, in parseImpl
    return super(ZeroOrMore, self).parseImpl(instring, loc, doActions)
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2841, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2924, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2841, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2924, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2841, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2924, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2841, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2924, in parseImpl
    loc, tokens = self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2841, in parseImpl
    loc, tokens = self_expr_parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2719, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2462, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1028, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 2576, in parseImpl
    ret = e._parse( instring, loc, doActions )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 1054, in _parseNoCache
    tokens = fn( instring, tokensStart, retTokens )
  File "/usr/lib/python2.7/dist-packages/pyparsing.py", line 792, in wrapper
    ret = func(*args[limit[0]:]) #~@$^*)+_(&%#!=-`~;:"[]{}
  File "/usr/lib/python2.7/dist-packages/rtslib/config_parser.py", line 228, in _parse_action_attr
    ref_path = " ".join(ref_path.asList())
AttributeError: 'list' object has no attribute 'asList'
rickysarraf commented 8 years ago

@agrover This issue may be of interest to you too ?

agrover commented 8 years ago

@rickysarraf I'm interested because this issue blocks writing a script that can convert between Datera's ".lio" file format and rtslib-fb's (json), but rtslib-fb itself is not affected.

rickysarraf commented 8 years ago

@tramjoe Could you please comment on this change? This fix was proposed by pyparsing author and it seems to fix the issue.