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

added access services api

parent 35423668
No related branches found
No related tags found
No related merge requests found
...@@ -210,6 +210,36 @@ name, ...@@ -210,6 +210,36 @@ name,
return r return r
def get_access_services(connection):
_sql = """
SELECT
c.absid AS id,
c.name,
pop_a.name as pop_name,
pop_b.name as other_end_pop_name,
e_a.name AS equipment,
e_b.name AS other_end_equipment,
c.speed_value,
c.speed_unit
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
WHERE LOWER(c.status) = 'operational'
AND LOWER(c.circuit_type) = 'service'
AND LOWER(c.service_type) = 'ip access'
AND c.is_circuit = 1
AND e_a.name IS NOT NULL
AND e_a.name != ''
ORDER BY name
"""
with db.cursor(connection) as crs:
crs.execute(_sql)
return _convert_to_dict(crs)
def get_circuit_hierarchy(connection): # pragma: no cover def get_circuit_hierarchy(connection): # pragma: no cover
_sql = """ _sql = """
...@@ -512,7 +542,7 @@ def get_service_users(connection, service_ids): ...@@ -512,7 +542,7 @@ def get_service_users(connection, service_ids):
if __name__ == '__main__': if __name__ == '__main__':
from inventory_provider.db import db from inventory_provider.db import db
import json
db_params = { db_params = {
'hostname': '83.97.93.8', 'hostname': '83.97.93.8',
'dbname': 'opsdb', 'dbname': 'opsdb',
...@@ -520,7 +550,7 @@ if __name__ == '__main__': ...@@ -520,7 +550,7 @@ if __name__ == '__main__':
'password': 'opsro' 'password': 'opsro'
} }
with db.connection(db_params) as cx: with db.connection(db_params) as cx:
circuits = get_circuits(cx) circuits = get_access_services(cx)
print(circuits) print(json.dumps(circuits))
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