diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index 4744a681f44d5d6ba781955bbe52473d1ee16a51..8a85d7e6ad1cac9db894b2730755addb6057b00f 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -701,9 +701,12 @@ def _build_subnet_db(update_callback=lambda s: None): subnets = {} # scan with bigger batches, to mitigate network latency effects for k in r.scan_iter('netconf-interfaces-hosts:*', count=1000): - host_interfaces = r.get(k.decode('utf-8')).decode('utf-8') + k = k.decode('utf-8') + hostname = k[len('netconf-interfaces-hosts:'):] + host_interfaces = r.get(k).decode('utf-8') host_interfaces = json.loads(host_interfaces) for ifc in host_interfaces: + ifc['router'] = hostname entry = subnets.setdefault(ifc['interface address'], []) entry.append(ifc)