... and the 'src_port_name' variable does not contain a valid name, the error would be something like this:
Traceback (most recent call last):
File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 136, in _get_attribute
return self._properties[name]
File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 122, in _properties
return self._object_properties[self._index]
IndexError: list index out of range
At this point, it is not possible to know if the topology or the deviceGroup name is invalid. Currently the best practice is to search for the topology first and verify if it returns an empty container and proceed next to the deviceGroup. This breaks the powerful chaining capability of the library.
I would propose in response to the initial RestPy command to instead of returning a generic 'list index out of range', to return an exception like: "Error: Topology not found" or something similar so the user know right away where the calling chain is broken.
If a user issues the following RestPy command ...
ix_network.Topology.find(Name=src_port_name).DeviceGroup.find(Name='Ethernet 19')
... and the 'src_port_name' variable does not contain a valid name, the error would be something like this:
Traceback (most recent call last): File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 136, in _get_attribute return self._properties[name] File "/home/lab/fb_gnmi/gNMI-API/venv/lib/python3.7/site-packages/ixnetwork_restpy/base.py", line 122, in _properties return self._object_properties[self._index] IndexError: list index out of range
At this point, it is not possible to know if the topology or the deviceGroup name is invalid. Currently the best practice is to search for the topology first and verify if it returns an empty container and proceed next to the deviceGroup. This breaks the powerful chaining capability of the library.
I would propose in response to the initial RestPy command to instead of returning a generic 'list index out of range', to return an exception like: "Error: Topology not found" or something similar so the user know right away where the calling chain is broken.