-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
Description
filing this bug on behalf of rwelch@arista.com
There's a reported traceback when doing portsVlans.getall():
Traceback (most recent call last):
File "automation.py", line 238, in <module>
setInterfaceVlans()
File "automation3.py", line 117, in setInterfaceVlans
currentVlans = portsVlans.getall()
File "C:\Python37\lib\site-packages\pyeapi\api\switchports.py", line 173, in getall
interface = self.get(name)
File "C:\Python37\lib\site-packages\pyeapi\api\switchports.py", line 85, in get
resource.update(self._parse_access_vlan(config))
File "C:\Python37\lib\site-packages\pyeapi\api\switchports.py", line 129, in _parse_access_vlan
return dict(access_vlan=value.group(1))
AttributeError: 'NoneType' object has no attribute 'group'I could not reproduce it on my dut:
>>> import pyeapi
>>> node = pyeapi.connect_to('mydut')
>>> portsVlans = node.api('switchports')
>>> currentVlans = portsVlans.getall()
>>> currentVlans
{'Ethernet2': {'access_vlan': '1', 'trunk_allowed_vlans': '1-4094', 'trunk_native_vlan': '1', 'mode': 'access', 'trunk_groups': [], 'name': 'Ethernet2'}}but it seems it's failing with just this in the reporter's setup:
portsVlans = connectedSwitch.api('switchports')
currentVlans = portsVlans.getall()The solution is a simple fix, e.g.: this line in switchports.py:
129 return dict( access_vlan=value.group(1) if value else None )