nauti-netdev / nauti

Network Automation Tools Integration Core Library
GNU General Public License v3.0
3 stars 1 forks source link

map_field_value object is not subscriptable #8

Open minitriga opened 3 years ago

minitriga commented 3 years ago

Getting the following error on siteName when trying to pull devices. Need to debug further.


2020-12-18 13:20:56,602 INFO: Fetching ipfabric/devices collection ...
2020-12-18 13:20:56,625 INFO: Fetched ipfabric/devices, fetched 16 records.
Collection devices: itimized failed.
Record: {'sn': '123123', 'hostname': 'EX4200-B15', 'siteName': 'Axians Lab', 'loginIp': '192.168.3.35', 'loginType': 'ssh', 'uptime': 44244660, 'vendor': 'juniper', 'platform': 'ex', 'family': 'junos', 'version': '12.3R12.4', 'model': 'ex4200-48t'}
Exception: 'NoneType' object is not subscriptable
Traceback: Traceback (most recent call last):
  File "/home/agitting/python/nauti/venv/lib/python3.8/site-packages/nauti/collection.py", line 213, in make_keys
    item = self.itemize(rec)
  File "/home/agitting/python/nauti/venv/lib/python3.8/site-packages/nauti_ipfabric/devices.py", line 66, in itemize
    site=self.map_field_value("site", rec["siteName"]),
TypeError: 'NoneType' object is not subscriptable```
minitriga commented 3 years ago

The collection toml for ipfabric (devices.toml) requires [sources.ipfabric.maps].

We should change this so that if [sources.ipfabric] is not present in configuration then its created by default. Also make maps optional?

devices.toml
[sources.ipfabric]

(venv) agitting@dev:~/python/nauti$ nauti sync --origin ipfabric --target netbox --collection devices --diff-report all
Configuration errors
    File:[/home/agitting/python/nauti/nauti.toml]
    Section: [collections.devices.sources.ipfabric.maps]: field required