diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py index 4e1236a998629e9f7ae402c14ae596c06e7968fb..0fb4238955116259e638f1157388b8277559d973 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")