Skip to content
Snippets Groups Projects
Commit b58af6fe authored by Erik Reid's avatar Erik Reid
Browse files

try to fix function call in worker

parent 666da0e2
No related branches found
No related tags found
No related merge requests found
......@@ -141,11 +141,19 @@ def update_equipment_locations():
logger.debug('>>> update_equipment_locations')
r = get_redis(InventoryTask.config)
for key in r.scan_iter('opsdb:location:*'):
r.delete(key)
for k in r.scan_iter('opsdb:location:*'):
r.delete(k)
hostnames = []
for k in r.keys('netconf:*'):
m = re.match('^netconf:(.+)$', k.decode('utf-8'))
assert m
hostnames.append(m.group(1))
with db.connection(InventoryTask.config["ops-db"]) as cx:
for ld in opsdb.lookup_pop_info(cx):
r.set('opsdb:location:%s' % ld['equipment_name'], json.dumps(ld))
for h in hostnames:
for ld in opsdb.lookup_pop_info(cx, h):
r.set('opsdb:location:%s' % h, json.dumps(ld))
logger.debug('<<< update_equipment_locations')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment