Skip to content
Snippets Groups Projects
Commit 07cc5ad9 authored by Robert Latta's avatar Robert Latta
Browse files

Updated SQL to get correct information for each end of services

parent 9093917f
Branches
Tags
No related merge requests found
...@@ -30,46 +30,47 @@ retrieve_services_query = """SELECT * ...@@ -30,46 +30,47 @@ retrieve_services_query = """SELECT *
LOWER(c.circuit_type) AS circuit_type, LOWER(c.circuit_type) AS circuit_type,
LOWER(c.service_type) AS service_type, LOWER(c.service_type) AS service_type,
events.short_descr AS project, events.short_descr AS project,
pop.name as pop_name, pop_a.name as pop_name,
pop.abbreviation as pop_abbreviation, pop_a.abbreviation as pop_abbreviation,
pop_b.name as other_end_pop_name, pop_b.name as other_end_pop_name,
pop_b.abbreviation as other_end_pop_abbreviation, pop_b.abbreviation as other_end_pop_abbreviation,
e.name AS equipment, e_a.name AS equipment,
e_b.name AS other_end_equipment, e_b.name AS other_end_equipment,
cc.port_a AS port, cc.port_a AS port,
cc.port_b AS other_end_port, cc.port_b AS other_end_port,
cc.int_LU_a AS logical_unit, cc.int_LU_a AS logical_unit,
cc.int_LU_b AS other_end_logical_unit, cc.int_LU_b AS other_end_logical_unit,
LOWER(o.name) AS manufacturer, LOWER(o.name) AS manufacturer,
LOWER(ec.card_id) AS card_id, LOWER(ec_a.card_id) AS card_id,
LOWER(ec_b.card_id) AS other_end_card_id, LOWER(ec_b.card_id) AS other_end_card_id,
LOWER( LOWER(
IF(pp.interface_name IS NULL, IF(pp_a.interface_name IS NULL,
'', pp.interface_name)) AS interface_name, '', pp_a.interface_name)) AS interface_name,
LOWER( LOWER(
IF(pp_b.interface_name IS NULL, IF(pp_b.interface_name IS NULL,
'', pp_b.interface_name)) AS other_end_interface_name '', pp_b.interface_name)) AS other_end_interface_name
FROM circuit c FROM circuit c
INNER JOIN circuit_connections cc INNER JOIN circuit_connections cc
ON cc.circ_absid = c.absid ON cc.circ_absid = c.absid
LEFT JOIN pop pop LEFT JOIN pop pop_a
ON pop.absid = cc.PTR_pop_a ON pop_a.absid = cc.PTR_pop_a
LEFT JOIN pop pop_b LEFT JOIN pop pop_b
ON pop_b.absid = cc.PTR_pop_b ON pop_b.absid = cc.PTR_pop_b
INNER JOIN equipment e INNER JOIN equipment e_a
ON e.absid = cc.PTR_equip_a ON e_a.absid = cc.PTR_equip_a
LEFT JOIN equipment e_b LEFT JOIN equipment e_b
ON e_b.absid = cc.PTR_equip_b ON e_b.absid = cc.PTR_equip_b
LEFT JOIN events LEFT JOIN events
ON events.absid = cc.PTR_project ON events.absid = cc.PTR_project
INNER JOIN equipment_card ec INNER JOIN equipment_card ec_a
ON ec.absid = cc.PTR_card_a ON ec_a.absid = cc.PTR_card_a
LEFT JOIN equipment_card ec_b LEFT JOIN equipment_card ec_b
ON ec_b.absid = cc.PTR_card_b ON ec_b.absid = cc.PTR_card_b
LEFT JOIN organisation o LEFT JOIN organisation o
ON o.absid = ec.manufacturer ON o.absid = ec_a.manufacturer
LEFT JOIN port_plugin pp LEFT JOIN port_plugin pp_a
ON pp.PTR_card = cc.PTR_card_a AND pp.port = cc.port_a ON pp_a.PTR_card = cc.PTR_card_a
AND pp_a.port = cc.port_a
LEFT JOIN port_plugin pp_b LEFT JOIN port_plugin pp_b
ON pp_b.PTR_card = cc.PTR_card_b ON pp_b.PTR_card = cc.PTR_card_b
AND pp_b.port = cc.port_b AND pp_b.port = cc.port_b
...@@ -82,46 +83,47 @@ retrieve_services_query = """SELECT * ...@@ -82,46 +83,47 @@ retrieve_services_query = """SELECT *
LOWER(c.circuit_type) AS circuit_type, LOWER(c.circuit_type) AS circuit_type,
LOWER(c.service_type) AS service_type, LOWER(c.service_type) AS service_type,
events.short_descr AS project, events.short_descr AS project,
pop.name as pop_name, pop_b.name as pop_name,
pop.abbreviation as pop_abbreviation, pop_b.abbreviation as pop_abbreviation,
pop_b.name as other_end_pop_name, pop_a.name as other_end_pop_name,
pop_b.abbreviation as other_end_pop_abbreviation, pop_a.abbreviation as other_end_pop_abbreviation,
e.name AS equipment, e_b.name AS equipment,
e_b.name AS other_end_equipment, e_a.name AS other_end_equipment,
cc.port_a AS port, cc.port_b AS port,
cc.port_b AS other_end_port, cc.port_a AS other_end_port,
cc.int_LU_a AS logical_unit, cc.int_LU_b AS logical_unit,
cc.int_LU_b AS other_end_logical_unit, cc.int_LU_a AS other_end_logical_unit,
LOWER(o.name) AS manufacturer, LOWER(o.name) AS manufacturer,
LOWER(ec.card_id) AS card_id, LOWER(ec_b.card_id) AS card_id,
LOWER(ec_b.card_id) AS other_end_card_id, LOWER(ec_a.card_id) AS other_end_card_id,
LOWER(
IF(pp.interface_name IS NULL,
'', pp.interface_name)) AS interface_name,
LOWER( LOWER(
IF(pp_b.interface_name IS NULL, IF(pp_b.interface_name IS NULL,
'', pp_b.interface_name)) AS other_end_interface_name '', pp_b.interface_name)) AS interface_name,
LOWER(
IF(pp_a.interface_name IS NULL,
'', pp_a.interface_name)) AS other_end_interface_name
FROM circuit c FROM circuit c
INNER JOIN circuit_connections cc INNER JOIN circuit_connections cc
ON cc.circ_absid = c.absid ON cc.circ_absid = c.absid
LEFT JOIN pop pop LEFT JOIN pop pop_a
ON pop.absid = cc.PTR_pop_a ON pop_a.absid = cc.PTR_pop_a
LEFT JOIN pop pop_b LEFT JOIN pop pop_b
ON pop_b.absid = cc.PTR_pop_b ON pop_b.absid = cc.PTR_pop_b
INNER JOIN equipment e INNER JOIN equipment e_a
ON e.absid = cc.PTR_equip_a ON e_a.absid = cc.PTR_equip_a
LEFT JOIN equipment e_b LEFT JOIN equipment e_b
ON e_b.absid = cc.PTR_equip_b ON e_b.absid = cc.PTR_equip_b
LEFT JOIN events LEFT JOIN events
ON events.absid = cc.PTR_project ON events.absid = cc.PTR_project
INNER JOIN equipment_card ec INNER JOIN equipment_card ec_a
ON ec.absid = cc.PTR_card_a ON ec_a.absid = cc.PTR_card_a
LEFT JOIN equipment_card ec_b LEFT JOIN equipment_card ec_b
ON ec_b.absid = cc.PTR_card_b ON ec_b.absid = cc.PTR_card_b
LEFT JOIN organisation o LEFT JOIN organisation o
ON o.absid = ec.manufacturer ON o.absid = ec_a.manufacturer
LEFT JOIN port_plugin pp LEFT JOIN port_plugin pp_a
ON pp.PTR_card = cc.PTR_card_a AND pp.port = cc.port_a ON pp_a.PTR_card = cc.PTR_card_a
AND pp_a.port = cc.port_a
LEFT JOIN port_plugin pp_b LEFT JOIN port_plugin pp_b
ON pp_b.PTR_card = cc.PTR_card_b ON pp_b.PTR_card = cc.PTR_card_b
AND pp_b.port = cc.port_b AND pp_b.port = cc.port_b
...@@ -129,6 +131,7 @@ retrieve_services_query = """SELECT * ...@@ -129,6 +131,7 @@ retrieve_services_query = """SELECT *
AS inner_query AS inner_query
WHERE circuit_type IN ('path', 'service', 'l2circuit') WHERE circuit_type IN ('path', 'service', 'l2circuit')
ORDER BY ORDER BY
name,
FIELD(status, FIELD(status,
'spare', 'spare',
'planned', 'planned',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment