napalm-automation/napalm-yang

Parsing Interface state of an Arista Fails

Closed this issue · 1 comments

When I try to parse the state of an Arista device I get the following traceback

Traceback (most recent call last):
  File "state.py", line 10, in <module>
    running_config.parse_state(device=device)
  File "/Users/tim/napalm-yang/napalm_yang/base.py", line 260, in parse_state
    parser.parse()
  File "/Users/tim/napalm-yang/napalm_yang/parser.py", line 81, in parse
    self.native = self.parser.init_native(self.native)
  File "/Users/tim/napalm-yang/napalm_yang/parsers/jsonp.py", line 28, in init_native
    resp.append(json.loads(k))
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 339, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 364, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer

I believe this is because the _execute_methods function in parser.py for the Arista gets the results back as list and then appends it to the result list. If I take the first element of the list that is returned by doing something like this in _execute_methods it parses.

if isinstance(r, list):
    r = r[0]
result.append(r)

But that doesn't seem to be the right solution otherwise you couldn't specify multiple commands to run in the yaml state file

This is fixed