From 686cc581e7536f0841c9c8ae3279a7f868c1bd00 Mon Sep 17 00:00:00 2001
From: Erik Reid <erik.reid@geant.org>
Date: Fri, 28 Feb 2020 14:04:29 +0100
Subject: [PATCH] Revert "added some variables to the services query
 conditions"

This reverts commit 6560530fbc36dadb5b9f8229a7e2307f64b06105.
---
 inventory_provider/db/opsdb.py | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/inventory_provider/db/opsdb.py b/inventory_provider/db/opsdb.py
index 32987081..91cffad1 100644
--- a/inventory_provider/db/opsdb.py
+++ b/inventory_provider/db/opsdb.py
@@ -31,8 +31,7 @@ circuit_hierarchy_query = """SELECT
                      LEFT JOIN events cp on cp.absid = cc.PTR_project"""
 
 
-def retrieve_services_query(types):
-    format = """SELECT *
+retrieve_services_query = """SELECT *
                     FROM (SELECT
                       c.absid AS id,
                       c.name,
@@ -142,7 +141,8 @@ def retrieve_services_query(types):
                     WHERE
                         equipment IS NOT NULL
                         AND equipment != ''
-                        AND circuit_type IN (%s)
+                        AND circuit_type IN (
+                          'path', 'service', 'l2circuit', 'link-aggr-group')
                     ORDER BY
                     name,
                      FIELD(status,
@@ -152,10 +152,6 @@ def retrieve_services_query(types):
                       'installed',
                       'operational')"""
 
-    assert types
-    types_string = "'" + "','".join(types) + "'"
-    return format % types_string
-
 
 def _convert_to_dict(crs):
     return [dict((crs.description[i][0], "" if value is None else value)
@@ -246,9 +242,9 @@ def get_geant_lambdas(connection):  # pragma: no cover
     return r
 
 
-def get_circuits(connection, types=['path', 'service', 'l2circuit', 'link-aggr-group']):
+def get_circuits(connection):
     with db.cursor(connection) as crs:
-        crs.execute(retrieve_services_query(types))
+        crs.execute(retrieve_services_query)
         r = _convert_to_dict(crs)
 
     r = list(map(_update_fields, r))
@@ -531,20 +527,3 @@ def get_service_users(connection, service_ids):
             crs.execute(query % ','.join([str(x) for x in chunk]))
             for r in crs.fetchall():
                 yield {'service_id': r[0], 'user': r[1]}
-
-
-if __name__ == '__main__':
-
-    from inventory_provider.db import db
-
-    db_params = {
-        'hostname': '83.97.93.8',
-        'dbname': 'opsdb',
-        'username': 'opsro',
-        'password': 'opsro'
-    }
-    with db.connection(db_params) as cx:
-        circuits = get_circuits(cx)
-
-    print(circuits)
-
-- 
GitLab