diff --git a/inventory_provider/db/opsdb.py b/inventory_provider/db/opsdb.py index 980bc73ca0f6612bd081f0678e3f014a576ede50..f9d9cf433fe6b50a88b8449e009f7fd706f92d26 100644 --- a/inventory_provider/db/opsdb.py +++ b/inventory_provider/db/opsdb.py @@ -58,6 +58,10 @@ retrieve_services_query = """SELECT * LOWER(c.circuit_type) AS circuit_type, LOWER(c.service_type) AS service_type, events.short_descr AS project, + pop.name as pop_name, + pop.abbreviation as pop_abbreviation, + pop_b.name as other_end_pop_name, + pop_b.abbreviation as other_end_pop_abbreviation, e.name AS equipment, e_b.name AS other_end_equipment, cc.port_a AS port, @@ -76,10 +80,14 @@ retrieve_services_query = """SELECT * FROM circuit c INNER JOIN circuit_connections cc ON cc.circ_absid = c.absid + LEFT JOIN pop pop + ON pop.absid = cc.PTR_pop_a + LEFT JOIN pop pop_b + ON pop_b.absid = cc.PTR_pop_b INNER JOIN equipment e ON e.absid = cc.PTR_equip_a LEFT JOIN equipment e_b - ON e_b.absid = cc.PTR_equip_B + ON e_b.absid = cc.PTR_equip_b LEFT JOIN events ON events.absid = cc.PTR_project INNER JOIN equipment_card ec @@ -102,12 +110,16 @@ retrieve_services_query = """SELECT * LOWER(c.circuit_type) AS circuit_type, LOWER(c.service_type) AS service_type, events.short_descr AS project, + pop.name as pop_name, + pop.abbreviation as pop_abbreviation, + pop_b.name as other_end_pop_name, + pop_b.abbreviation as other_end_pop_abbreviation, e.name AS equipment, e_b.name AS other_end_equipment, - cc.port_b AS port, - cc.port_a AS other_end_port, - cc.int_LU_b AS logical_unit, - cc.int_LU_a AS other_end_logical_unit, + cc.port_a AS port, + cc.port_b AS other_end_port, + cc.int_LU_a AS logical_unit, + cc.int_LU_b AS other_end_logical_unit, LOWER(o.name) AS manufacturer, LOWER(ec.card_id) AS card_id, LOWER(ec_b.card_id) AS other_end_card_id, @@ -120,23 +132,27 @@ retrieve_services_query = """SELECT * FROM circuit c INNER JOIN circuit_connections cc ON cc.circ_absid = c.absid + LEFT JOIN pop pop + ON pop.absid = cc.PTR_pop_a + LEFT JOIN pop pop_b + ON pop_b.absid = cc.PTR_pop_b INNER JOIN equipment e - ON e.absid = cc.PTR_equip_b + ON e.absid = cc.PTR_equip_a LEFT JOIN equipment e_b - ON e_b.absid = cc.PTR_equip_a + ON e_b.absid = cc.PTR_equip_b LEFT JOIN events ON events.absid = cc.PTR_project INNER JOIN equipment_card ec - ON ec.absid = cc.PTR_card_b + ON ec.absid = cc.PTR_card_a LEFT JOIN equipment_card ec_b - ON ec_b.absid = cc.PTR_card_a + ON ec_b.absid = cc.PTR_card_b LEFT JOIN organisation o ON o.absid = ec.manufacturer LEFT JOIN port_plugin pp - ON pp.PTR_card = cc.PTR_card_b AND pp.port = cc.port_b + ON pp.PTR_card = cc.PTR_card_a AND pp.port = cc.port_a LEFT JOIN port_plugin pp_b - ON pp_b.PTR_card = cc.PTR_card_a - AND pp_b.port = cc.port_a + ON pp_b.PTR_card = cc.PTR_card_b + AND pp_b.port = cc.port_b WHERE c.status != 'terminated' AND is_circuit = 1) AS inner_query WHERE circuit_type IN ('path', 'service', 'l2circuit') @@ -198,7 +214,7 @@ def _update_fields(r): return func(r) if func else r -def get_geant_lambdas(connection): +def get_geant_lambdas(connection): # pragma: no cover with db.cursor(connection) as crs: crs.execute(geant_lambda_sql) r = _convert_to_dict(crs) @@ -214,14 +230,14 @@ def get_circuits(connection): return r -def get_circuit_hierarchy(connection): +def get_circuit_hierarchy(connection): # pragma: no cover with db.cursor(connection) as crs: crs.execute(circuit_hierarchy_query) r = _convert_to_dict(crs) return r -def get_equipment_location_data(connection): +def get_equipment_location_data(connection): # pragma: no cover with db.cursor(connection) as crs: crs.execute(equipment_location_query) r = _convert_to_dict(crs)