Skip to content

IndexError: string index out of range #286

@sc68cal

Description

@sc68cal

I am trying to use pyEAPI with an Arista switch, and it appears that the code is broken, since all the API calls (vlans, bgp, etc) do not work...

>>> conn = pyeapi.connect(host='REDACTED', transport='http')
>>> conn.execute('show version')
{'jsonrpc': '2.0', 'id': '4378960720', 'result': [{'imageFormatVersion': '3.0', 'uptime': 6903160.73, 'modelName': 'DCS-7280SR2-48YC6-R', 'internalVersion': '4.28.3M-28837868.4283M', 'memTotal': 8098932, 'mfgName': 'Arista', 'serialNumber': '', 'systemMacAddress': '', 'bootupTimestamp': 1687730683.544857, 'memFree': 5698516, 'version': '4.28.3M', 'configMacAddress': '00:00:00:00:00:00', 'isIntlVersion': False, 'imageOptimization': 'Sand-4GB', 'internalBuildId': 'f6ff9a13-c989-4fe6-a396-a510e5d33302', 'hardwareRevision': '11.00', 'hwMacAddress': '', 'architecture': 'i686'}]}
#show running-config section vlan
spanning-tree vlan-id 1-3967 priority 4096
no vlan 1
vlan 4
   name REDACTED
vlan 10
   name REDACTD 
vlan 48
   name REDACTED
vlan 49
   name REDACTED
vlan 50
   name REDACTED
vlan 520
   name REDACTED
vlan 521
   name REDACTED
vlan 801
   name REDACTED
vlan 2999
   name REDACTED
vlan 3966
   name REDACTED
vlan 3967
   name REDACTED
vlan 4094
   name REDACTED
   trunk group mlagpeer
interface Port-Channel57.5
   encapsulation dot1q vlan 5
interface Port-Channel59.5
   encapsulation dot1q vlan 5
interface Ethernet34
   switchport access vlan 521
interface Ethernet35
   switchport access vlan 521
interface Ethernet36
   switchport access vlan 521
interface Ethernet38
   switchport access vlan 521
interface Ethernet39
   switchport access vlan 521
interface Ethernet40
   switchport access vlan 521
interface Ethernet42
   switchport access vlan 521
interface Ethernet43
   switchport access vlan 521

pip freeze | grep 'pyeapi'
pyeapi==1.0.2
>>> print(node.api('vlans').getall())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<snip>/pyeapi/api/vlans.py", line 191, in getall
    response[vid] = self.get(vid)
  File "<snip>/pyeapi/api/vlans.py", line 104, in get
    config = self.get_block('vlan %s' % value)
  File "<snip>/pyeapi/api/abstract.py", line 99, in get_block
    return self.node.section(parent, config=config)
  File "<snip>/pyeapi/client.py", line 759, in section
    chunked = self._chunkify(config)
  File "<snip>/pyeapi/client.py", line 734, in _chunkify
    if is_subsection_present( lines, ind ):
  File "<snip>/pyeapi/client.py", line 721, in is_subsection_present
    return any( [line[ indent ] == ' ' for line in section] )
  File "<snip>/pyeapi/client.py", line 721, in <listcomp>
    return any( [line[ indent ] == ' ' for line in section] )
IndexError: string index out of range

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions