dainok / netdoc

Automatic Network Documentation plugin for NetBox
GNU General Public License v3.0
89 stars 13 forks source link

discover fail #15

Closed mamingzhi945 closed 1 year ago

mamingzhi945 commented 1 year ago

environment:Install using docker comment: After clicking discoverable, the business does not change the data. Execute the command docker-compose logs netbox-worker。

netbox-docker-netbox-worker-1  | 08:38:03 default: extras.scripts.run_script(data={'discoverables': [<Discoverable: 10.62.192.6 via netmiko_cisco_ios>]}, job_result=<JobResult: 05b95547-5148-415e-a8b7-67cc9914b09c>, request=<utilities.utils.NetBoxFakeRequest object at 0x7f94956c3d60>) (05b95547-5148-415e-a8b7-67cc9914b09c)
netbox-docker-netbox-worker-1  | ['10.62.192.6']
netbox-docker-netbox-worker-1  | dict_keys([])
netbox-docker-netbox-worker-1  | Nornir inventory is empty
netbox-docker-netbox-worker-1  | 08:38:03 default: Job OK (05b95547-5148-415e-a8b7-67cc9914b09c)
netbox-docker-netbox-worker-1  | 08:38:03 Result is kept for 500 seconds

what to do in this situation?

dainok commented 1 year ago

In NetBox -> Other -> Jobs you can see details. Please copy and paste. From what I read, the NetDoc tried to discover 10.62.192.6 and something working, but I cannot say what.

mamingzhi945 commented 1 year ago

log:

Line Level Message
1 Info Starting discovery on 10.62.192.6
2 Failure Nornir inventory is empty

output None


source

class Discover(Script):
    """Script used to start discovery."""

    class Meta:
        """Script metadata."""

        name = "Discover"
        description = "Start discovery on one, many or all discoverables."
        commit_default = True

    # Discoverable
    discoverables = MultiObjectVar(
        model=Discoverable_m,
        query_params={
            "discoverable": True
        },  # TODO: not working, discoverable=False are also showed (cosmetic).
        description="Devices to be discovered (leave empty to discover everything).",
        required=False,
    )

    # Ingested?
    undiscovered_only = BooleanVar(
        description="Undiscovered devices only (the above setting is ignored).",
        required=False,
        default=True,
    )

    def run(self, data, commit):
        """Start the script."""
        discoverable_ip_addresses = []
        discoverables = data.get("discoverables")

        # Filtering out discoverable=False is done at Nornir inventory level.

        if data.get("undiscovered_only"):
            # Get only undiscovered IP addresses
            discoverables = discoverable.get_list(last_discovered_at__isnull=True)
            for discoverable_o in discoverables:
                discoverable_ip_addresses.append(discoverable_o.address)

            self.log_info(
                f"Starting first discovery on {', '.join(discoverable_ip_addresses)}"
            )
            output = discovery(discoverable_ip_addresses, script_handler=self)
        elif discoverables:
            for discoverable_o in discoverables:
                discoverable_ip_addresses.append(discoverable_o.address)

            self.log_info(
                f"Starting discovery on {', '.join(discoverable_ip_addresses)}"
            )
            output = discovery(discoverable_ip_addresses, script_handler=self)
        else:
            self.log_info("Starting discovery on all IP addresses")
            output = discovery(None, script_handler=self)
dainok commented 1 year ago

seems your discoverable has not the "discoverable=True" flag. Can you post a screenshot of NetDoc -> Discoverable?

mamingzhi945 commented 1 year ago

thanks,I overlooked this optional field.

However, there is a new Ingest error. I will first take a look at the logs myself.

mamingzhi945 commented 1 year ago

The route table of nxos has a similar protocol: *via 10.122.208.xx, Eth1/2, [110/0], 16w3d, ospf-UNDERLAY, type-2 Maybe this regular expression needs to be modified。 /opt/netbox/venv/lib/python3.10/site-packages/netdoc/ingestors/netmiko_cisco_nxos_show_ip_route_vrf_all.py", line 29, in ingest

dainok commented 1 year ago

Because this is an ingestion issue, could you open a separated issue and attach logs and full exception?

dainok commented 1 year ago

@mamingzhi945 you have closed this issue, but I don't get if you are still encountering the issue or everything is fine.