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