aristanetworks/cvprac

Need to handle no elements returned for query

Closed this issue · 0 comments

For get_device_by_name() (and maybe others) if the item being queried for doesn't exist, then the following is returned:

{
  "total": 0,
  "netElementList": [],
  "containerList": {}
}

which yields this error:

  File "/Users/cwomble/work/cvprac/cvprac/cvp_api.py", line 252, in get_device_by_name
    return data['netElementList'][0]
IndexError: list index out of range

Need to handle such cases.