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

whitespace

parent 0566ea90
No related branches found
No related tags found
No related merge requests found
...@@ -85,17 +85,18 @@ def _update_fields(r): ...@@ -85,17 +85,18 @@ def _update_fields(r):
def get_geant_lambdas(connection): # pragma: no cover def get_geant_lambdas(connection): # pragma: no cover
_sql = """SELECT _sql = """
c.absid AS id, SELECT
c.name as name, c.absid AS id,
LOWER(c.status) AS status, c.name as name,
p.short_descr as project LOWER(c.status) AS status,
FROM vcircuitconns c p.short_descr as project
left join events p FROM vcircuitconns c
on p.absid = c.PTR_project left join events p on p.absid = c.PTR_project
WHERE WHERE
c.status != 'terminated' c.status != 'terminated'
AND c.service_type = 'geant lambda'""" AND c.service_type = 'geant lambda'
"""
with db.cursor(connection) as crs: with db.cursor(connection) as crs:
crs.execute(_sql) crs.execute(_sql)
...@@ -104,126 +105,128 @@ def get_geant_lambdas(connection): # pragma: no cover ...@@ -104,126 +105,128 @@ def get_geant_lambdas(connection): # pragma: no cover
def get_circuits(connection): def get_circuits(connection):
_sql = """SELECT * _sql = """
FROM (SELECT SELECT *
c.absid AS id, FROM (SELECT
c.name, c.absid AS id,
LOWER(c.status) AS status, c.name,
LOWER(c.circuit_type) AS circuit_type, LOWER(c.status) AS status,
LOWER(c.service_type) AS service_type, LOWER(c.circuit_type) AS circuit_type,
events.short_descr AS project, LOWER(c.service_type) AS service_type,
pop_a.name as pop_name, events.short_descr AS project,
pop_a.abbreviation as pop_abbreviation, pop_a.name as pop_name,
pop_b.name as other_end_pop_name, pop_a.abbreviation as pop_abbreviation,
pop_b.abbreviation as other_end_pop_abbreviation, pop_b.name as other_end_pop_name,
e_a.name AS equipment, pop_b.abbreviation as other_end_pop_abbreviation,
e_b.name AS other_end_equipment, e_a.name AS equipment,
cc.port_a AS port, e_b.name AS other_end_equipment,
cc.port_b AS other_end_port, cc.port_a AS port,
cc.int_LU_a AS logical_unit, cc.port_b AS other_end_port,
cc.int_LU_b AS other_end_logical_unit, cc.int_LU_a AS logical_unit,
LOWER(o.name) AS manufacturer, cc.int_LU_b AS other_end_logical_unit,
LOWER(ec_a.card_id) AS card_id, LOWER(o.name) AS manufacturer,
LOWER(ec_b.card_id) AS other_end_card_id, LOWER(ec_a.card_id) AS card_id,
LOWER( LOWER(ec_b.card_id) AS other_end_card_id,
IF(pp_a.interface_name IS NULL, LOWER(
'', pp_a.interface_name)) AS interface_name, IF(pp_a.interface_name IS NULL,
LOWER( '', pp_a.interface_name)) AS interface_name,
IF(pp_b.interface_name IS NULL, LOWER(
'', pp_b.interface_name)) AS other_end_interface_name IF(pp_b.interface_name IS NULL,
FROM circuit c '', pp_b.interface_name)) AS other_end_interface_name
INNER JOIN circuit_connections cc FROM circuit c
ON cc.circ_absid = c.absid INNER JOIN circuit_connections cc
LEFT JOIN pop pop_a ON cc.circ_absid = c.absid
ON pop_a.absid = cc.PTR_pop_a LEFT JOIN pop pop_a
LEFT JOIN pop pop_b ON pop_a.absid = cc.PTR_pop_a
ON pop_b.absid = cc.PTR_pop_b LEFT JOIN pop pop_b
INNER JOIN equipment e_a ON pop_b.absid = cc.PTR_pop_b
ON e_a.absid = cc.PTR_equip_a INNER JOIN equipment e_a
LEFT JOIN equipment e_b ON e_a.absid = cc.PTR_equip_a
ON e_b.absid = cc.PTR_equip_b LEFT JOIN equipment e_b
LEFT JOIN events ON e_b.absid = cc.PTR_equip_b
ON events.absid = cc.PTR_project LEFT JOIN events
INNER JOIN equipment_card ec_a ON events.absid = cc.PTR_project
ON ec_a.absid = cc.PTR_card_a INNER JOIN equipment_card ec_a
LEFT JOIN equipment_card ec_b ON ec_a.absid = cc.PTR_card_a
ON ec_b.absid = cc.PTR_card_b LEFT JOIN equipment_card ec_b
LEFT JOIN organisation o ON ec_b.absid = cc.PTR_card_b
ON o.absid = ec_a.manufacturer LEFT JOIN organisation o
LEFT JOIN port_plugin pp_a ON o.absid = ec_a.manufacturer
ON pp_a.PTR_card = cc.PTR_card_a LEFT JOIN port_plugin pp_a
AND pp_a.port = cc.port_a ON pp_a.PTR_card = cc.PTR_card_a
LEFT JOIN port_plugin pp_b AND pp_a.port = cc.port_a
ON pp_b.PTR_card = cc.PTR_card_b LEFT JOIN port_plugin pp_b
AND pp_b.port = cc.port_b ON pp_b.PTR_card = cc.PTR_card_b
WHERE c.status != 'terminated' AND is_circuit = 1 AND pp_b.port = cc.port_b
UNION WHERE c.status != 'terminated' AND is_circuit = 1
SELECT UNION
c.absid AS id, SELECT
c.name, c.absid AS id,
LOWER(c.status) AS status, c.name,
LOWER(c.circuit_type) AS circuit_type, LOWER(c.status) AS status,
LOWER(c.service_type) AS service_type, LOWER(c.circuit_type) AS circuit_type,
events.short_descr AS project, LOWER(c.service_type) AS service_type,
pop_b.name as pop_name, events.short_descr AS project,
pop_b.abbreviation as pop_abbreviation, pop_b.name as pop_name,
pop_a.name as other_end_pop_name, pop_b.abbreviation as pop_abbreviation,
pop_a.abbreviation as other_end_pop_abbreviation, pop_a.name as other_end_pop_name,
e_b.name AS equipment, pop_a.abbreviation as other_end_pop_abbreviation,
e_a.name AS other_end_equipment, e_b.name AS equipment,
cc.port_b AS port, e_a.name AS other_end_equipment,
cc.port_a AS other_end_port, cc.port_b AS port,
cc.int_LU_b AS logical_unit, cc.port_a AS other_end_port,
cc.int_LU_a AS other_end_logical_unit, cc.int_LU_b AS logical_unit,
LOWER(o.name) AS manufacturer, cc.int_LU_a AS other_end_logical_unit,
LOWER(ec_b.card_id) AS card_id, LOWER(o.name) AS manufacturer,
LOWER(ec_a.card_id) AS other_end_card_id, LOWER(ec_b.card_id) AS card_id,
LOWER( LOWER(ec_a.card_id) AS other_end_card_id,
IF(pp_b.interface_name IS NULL, LOWER(
'', pp_b.interface_name)) AS interface_name, IF(pp_b.interface_name IS NULL,
LOWER( '', pp_b.interface_name)) AS interface_name,
IF(pp_a.interface_name IS NULL, LOWER(
'', pp_a.interface_name)) AS other_end_interface_name IF(pp_a.interface_name IS NULL,
FROM circuit c '', pp_a.interface_name)) AS other_end_interface_name
INNER JOIN circuit_connections cc FROM circuit c
ON cc.circ_absid = c.absid INNER JOIN circuit_connections cc
LEFT JOIN pop pop_a ON cc.circ_absid = c.absid
ON pop_a.absid = cc.PTR_pop_a LEFT JOIN pop pop_a
LEFT JOIN pop pop_b ON pop_a.absid = cc.PTR_pop_a
ON pop_b.absid = cc.PTR_pop_b LEFT JOIN pop pop_b
LEFT JOIN equipment e_a ON pop_b.absid = cc.PTR_pop_b
ON e_a.absid = cc.PTR_equip_a LEFT JOIN equipment e_a
INNER JOIN equipment e_b ON e_a.absid = cc.PTR_equip_a
ON e_b.absid = cc.PTR_equip_b INNER JOIN equipment e_b
LEFT JOIN events ON e_b.absid = cc.PTR_equip_b
ON events.absid = cc.PTR_project LEFT JOIN events
LEFT JOIN equipment_card ec_a ON events.absid = cc.PTR_project
ON ec_a.absid = cc.PTR_card_a LEFT JOIN equipment_card ec_a
INNER JOIN equipment_card ec_b ON ec_a.absid = cc.PTR_card_a
ON ec_b.absid = cc.PTR_card_b INNER JOIN equipment_card ec_b
LEFT JOIN organisation o ON ec_b.absid = cc.PTR_card_b
ON o.absid = ec_b.manufacturer LEFT JOIN organisation o
LEFT JOIN port_plugin pp_a ON o.absid = ec_b.manufacturer
ON pp_a.PTR_card = cc.PTR_card_a LEFT JOIN port_plugin pp_a
AND pp_a.port = cc.port_a ON pp_a.PTR_card = cc.PTR_card_a
LEFT JOIN port_plugin pp_b AND pp_a.port = cc.port_a
ON pp_b.PTR_card = cc.PTR_card_b LEFT JOIN port_plugin pp_b
AND pp_b.port = cc.port_b ON pp_b.PTR_card = cc.PTR_card_b
WHERE c.status != 'terminated' AND is_circuit = 1) AND pp_b.port = cc.port_b
AS inner_query WHERE c.status != 'terminated' AND is_circuit = 1)
WHERE AS inner_query
equipment IS NOT NULL WHERE
AND equipment != '' equipment IS NOT NULL
AND circuit_type IN ( AND equipment != ''
'path', 'service', 'l2circuit', 'link-aggr-group') AND circuit_type IN (
ORDER BY 'path', 'service', 'l2circuit', 'link-aggr-group')
name, ORDER BY
FIELD(status, name,
'spare', FIELD(status,
'planned', 'spare',
'ordered', 'planned',
'installed', 'ordered',
'operational')""" 'installed',
'operational')
"""
with db.cursor(connection) as crs: with db.cursor(connection) as crs:
crs.execute(_sql) crs.execute(_sql)
...@@ -235,23 +238,25 @@ def get_circuits(connection): ...@@ -235,23 +238,25 @@ def get_circuits(connection):
def get_circuit_hierarchy(connection): # pragma: no cover def get_circuit_hierarchy(connection): # pragma: no cover
_sql = """SELECT _sql = """
pc.name AS parent_circuit, SELECT
pc.absid AS parent_circuit_id, pc.name AS parent_circuit,
pc.circuit_type AS parent_circuit_type, pc.absid AS parent_circuit_id,
LOWER(pc.status) AS parent_circuit_status, pc.circuit_type AS parent_circuit_type,
pp.short_descr AS parent_project, LOWER(pc.status) AS parent_circuit_status,
cc.name AS child_circuit, pp.short_descr AS parent_project,
cc.absid AS child_circuit_id, cc.name AS child_circuit,
cc.circuit_type AS child_circuit_type, cc.absid AS child_circuit_id,
LOWER(cc.status) AS child_circuit_status, cc.circuit_type AS child_circuit_type,
cp.short_descr AS child_project, LOWER(cc.status) AS child_circuit_status,
cg.segment_group AS segment_group cp.short_descr AS child_project,
FROM circuit_glue cg cg.segment_group AS segment_group
INNER JOIN vcircuitconns pc ON pc.absid = cg.PTR_circuit FROM circuit_glue cg
INNER JOIN vcircuitconns cc ON cc.absid = cg.PTR_component INNER JOIN vcircuitconns pc ON pc.absid = cg.PTR_circuit
LEFT JOIN events pp on pp.absid = pc.PTR_project INNER JOIN vcircuitconns cc ON cc.absid = cg.PTR_component
LEFT JOIN events cp on cp.absid = cc.PTR_project""" LEFT JOIN events pp on pp.absid = pc.PTR_project
LEFT JOIN events cp on cp.absid = cc.PTR_project
"""
with db.cursor(connection) as crs: with db.cursor(connection) as crs:
crs.execute(_sql) crs.execute(_sql)
...@@ -332,7 +337,7 @@ WHERE ...@@ -332,7 +337,7 @@ WHERE
AND e.status = 'Operational' AND e.status = 'Operational'
AND o.name = 'DANTE / GEANT' AND o.name = 'DANTE / GEANT'
AND NOT (e.name REGEXP 'vpn-proxy|vrr|taas') AND NOT (e.name REGEXP 'vpn-proxy|vrr|taas')
""" """
def _row2rsp(row): def _row2rsp(row):
print(row) print(row)
...@@ -530,6 +535,7 @@ def get_service_users(connection, service_ids): ...@@ -530,6 +535,7 @@ def get_service_users(connection, service_ids):
yield {'service_id': r[0], 'user': r[1]} yield {'service_id': r[0], 'user': r[1]}
if __name__ == '__main__': if __name__ == '__main__':
from inventory_provider.db import db from inventory_provider.db import db
......
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