From 356c8bba0b4bfe6b1655885a831e7191472dd7e3 Mon Sep 17 00:00:00 2001 From: Robert Latta <robert.latta@geant.org> Date: Tue, 8 Jan 2019 08:32:35 +0000 Subject: [PATCH] Updated routes related to external-inventroy(opsdb) updates --- inventory_provider/routes/jobs.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py index 4e1236a9..0fb42389 100644 --- a/inventory_provider/routes/jobs.py +++ b/inventory_provider/routes/jobs.py @@ -58,33 +58,36 @@ def update_interfaces(): return Response("OK") -@routes.route("update-equipment-locations", methods=['GET']) -def update_equipment_locations(): +@routes.route("update-service-hierarchy", methods=['GET']) +def update_service_hierarchy(): config = current_app.config['INVENTORY_PROVIDER_CONFIG'] with opsdb.connection(config['ops-db']) as db: - result = opsdb.get_equipment_location_data(db) - external_inventory.update_equipment_locations(result) + result = opsdb.get_circuit_hierarchy(db) + external_inventory.update_service_hierarchy(result) return Response("OK") -@routes.route("update-from-inventory-system", methods=['GET']) -def update_from_inventory_system(): +@routes.route("update-equipment-locations", methods=['GET']) +def update_equipment_locations(): config = current_app.config['INVENTORY_PROVIDER_CONFIG'] with opsdb.connection(config['ops-db']) as db: - result = opsdb.get_circuits(db) - external_inventory.update_services_to_monitor(result) - external_inventory.update_interfaces_to_services(result) - # todo - add other updates + result = opsdb.get_equipment_location_data(db) + external_inventory.update_equipment_locations(result) return Response("OK") -@routes.route("update-service-hierarchy", methods=['GET']) -def update_service_hierarchy(): +@routes.route("update-from-inventory-system", methods=['GET']) +def update_from_inventory_system(): config = current_app.config['INVENTORY_PROVIDER_CONFIG'] with opsdb.connection(config['ops-db']) as db: - result = opsdb.get_circuit_hierarchy(db) - external_inventory.update_service_hierarchy(result) + circuits = opsdb.get_circuits(db) + hierarchy = opsdb.get_circuit_hierarchy(db) + equipment_locations = opsdb.get_equipment_location_data(db) + external_inventory.update_services_to_monitor(circuits) + external_inventory.update_interfaces_to_services(circuits) + external_inventory.update_service_hierarchy(hierarchy) + external_inventory.update_equipment_locations(equipment_locations) return Response("OK") -- GitLab