networktocode/network-importer

Traceback at Import Network Model step

dbbtuss opened this issue · 7 comments

Environment

  • Python version: 3.9
  • Network Importer version: Latest - 3.1.0
  • Nautobot version: 1.5.10

Steps to Reproduce

  1. Run network-importer check --config network_importer.toml

Expected Behavior

Run normally

Observed Behavior

Traceback at Import Network Model step (below).

[~]$ network-importer check --config network_importer.toml
2023-03-15 07:18:46,275 - network-importer - INFO - Import SOT Model
2023-03-15 07:18:47,163 - network-importer - DEBUG - Nautobot | Found 15 interfaces for LAB1-MID
2023-03-15 07:18:47,207 - network-importer - DEBUG - Nautobot | Found 1 ip addresses for LAB1-MID
2023-03-15 07:18:47,327 - network-importer - DEBUG - Nautobot | Found 15 interfaces for lab02.<redacted>
2023-03-15 07:18:47,380 - network-importer - DEBUG - Nautobot | Found 1 ip addresses for lab02.<redacted>
2023-03-15 07:18:47,487 - network-importer - DEBUG - Nautobot | Found 15 interfaces for sr01.<redacted>
2023-03-15 07:18:47,548 - network-importer - DEBUG - Nautobot | Found 1 ip addresses for sr01.<redacted>
2023-03-15 07:18:47,577 - network-importer - DEBUG - Nautobot | Found 0 cables in nautobot for site-one-lab
2023-03-15 07:18:47,609 - network-importer - DEBUG - Nautobot | Found 0 cables in nautobot for another-site-name
2023-03-15 07:18:47,609 - network-importer - INFO - Import Network Model
Traceback (most recent call last):
  File "/home/<redacted>/.local/bin/network-importer", line 8, in <module>
    sys.exit(main())
  File "/home/<redacted>/.local/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/<redacted>/.local/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/network_importer/cli.py", line 148, in check
    ni.init(limit=limit)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/network_importer/performance.py", line 67, in timed
    result = method(*args, **kw)
  File "/home/<redacted>/.local/lib/python3.9/site-packages/network_importer/main.py", line 128, in init
    self.network.load()
  File "/home/<redacted>/.local/lib/python3.9/site-packages/network_importer/adapters/network_importer/adapter.py", line 46, in load
    self.init_batfish()
  File "/home/<redacted>/.local/lib/python3.9/site-packages/network_importer/adapters/network_importer/adapter.py", line 100, in init_batfish
    error = json.loads(str(exc).splitlines()[-1])
  File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python3.9/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Config file:

[main]
import_ips = true
import_prefixes = true
# import_cabling = "config"       # Valid options are ["lldp", "cdp", "config", false]
# import_intf_status = false     # If set as False, interface status will be ignore all together
# import_vlans = "config"         # Valid options are ["cli", "config", true, false]
# excluded_platforms_cabling = ["cisco_asa"]

# Directory where the configurations can be find, organized in Batfish format
# configs_directory= "configs"

backend = "nautobot"            # Valid options are ["nautobot", "netbox"]

[inventory]
# Define a list of supported platform,
# if defined all devices without platform or with a different platforms will be removed from the inventory
# supported_platforms = [ "cisco_ios", "cisco_nxos" ]

[inventory.settings]
# The information to connect to Nautobot needs to be provided, either in the config file or as environment variables
# These settings are specific to the Nautobot inventory, please check the documentation of your inventory for the
# exist list of of available settings.
address = "http://<redacted IP address>"                   # Alternative Env Variable : NAUTOBOT_ADDRESS
token = "<redacted>"  # Alternative Env Variable : NAUTOBOT_TOKEN
verify_ssl = false                                   # Alternative Env Variable : NAUTOBOT_VERIFY_SSL

[network]
# To be able to pull live information from the devices, the credential information needs to be provided
# either in the configuration file or as environment variables ( & NETWORK_DEVICE_PWD)
login = "<redacted>"      # Alternative Env Variable : NETWORK_DEVICE_LOGIN
password = "<redacted>"   # Alternative Env Variable : NETWORK_DEVICE_PWD

[batfish]
address= "localhost"    # Alternative Env Variable : BATFISH_ADDRESS
# api_key = "XXXX"      # Alternative Env Variable : BATFISH_API_KEY
# use_ssl = false

[logs]
# Define log level, currently the logs are printed on the screen
level = "debug" # "debug", "info", "warning"

I think this might be an issue with the information received from Batfish. Which batfish do you have running and how is it installed?

I had a similar error, I set configs_directory in network_importer.toml, the value is the path where the configs folder is.

In my case:
configs_directory = "/var/nautobot/git/back-config/golden_config/backup/lab"

Routers configs are stored in "/var/nautobot/git/back-config/golden_config/backup/lab/configs"

See: https://github.com/batfish/batfish/wiki/Packaging-snapshots-for-analysis

Interesting - I tried that, no go. But my configs are located in site-specific subfolders, I'm not sure if that matters?

Ex: "/var/nautobot/git/back-config/golden_config/backup-configs/Site1"

And it appears the Golden Config plugin adds single quotes around sites with spaces in the name, perhaps I should name the folders based on the slug instead?

Ex: /var/nautobot/git/back-config/golden_config/backup-configs/'Site 2'"

What are the device types in this?

@dbbtuss yes, Batfish expects the configs to be laid out pretty specifically. Will see if I can get that order when there are sites. I believe it doesn't really have a site information associated with it.

Working with @scetron we figured out the issue. I needed to place the configs under the "configs" subfolder under the site name - akin to:

"/var/nautobot/git/back-config/golden_config/backup-configs/Site1/configs/file.cfg"