From d0a763fd655ca475479bcee53e5f23e43c145595 Mon Sep 17 00:00:00 2001
From: Patrick Karl Czodrowski <patrick.czodrowski@cern.ch>
Date: Tue, 27 Sep 2022 21:35:55 +0200
Subject: [PATCH] remove plain passwds in scripts ATR-25572

remove plain passwds in scripts ATR-25572
---
 .../TrigT1CTMonitoring/scripts/CoolHelper.py  | 46 +++++++++++++++++--
 .../scripts/ReadPbmCounters.py                | 44 +++++++++++++++++-
 .../scripts/check_ctp_deadtime.py             | 21 ++++++++-
 .../scripts/cool_read_livetime.py             | 21 ++++++++-
 .../scripts/cool_read_lvl1rates.py            | 21 ++++++++-
 .../scripts/cool_read_lvl1rates_get_lumi.py   | 21 ++++++++-
 .../scripts/fillLVL1histograms.py             | 21 ++++++++-
 .../TrigT1CTMonitoring/scripts/l1ctpy.py      | 43 +++++++++++++++--
 .../scripts/read_bunchgroups.py               | 21 ++++++++-
 9 files changed, 245 insertions(+), 14 deletions(-)

diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/CoolHelper.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/CoolHelper.py
index d48768a85509..f1197bd72fc6 100644
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/CoolHelper.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/CoolHelper.py
@@ -1,6 +1,6 @@
 # Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
 
-import sys
+import sys, os
 from PyCool import cool,coral
 from CoolConvUtilities import AtlCoolTool
 from AtlDataSummary.AtlDataSumLumiData import LumiBCIDData
@@ -16,7 +16,27 @@ def openDb(MONP = False, TDAQ = False):
     if MONP : schemaName = "MONP200"
     accountName = "ATLAS_COOLONL_TRIGGER"
     if TDAQ : accountName = "ATLAS_COOLONL_TDAQ"
-    dbstring="oracle://ATLAS_COOLPROD;schema="+accountName+";dbname="+schemaName+";user=ATLAS_COOL_READER;password=COOLRED4PRO"
+    # Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+    # see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+    connName="oracle://ATLAS_COOLPROD/"+accountName # aka. schema 
+    dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+    dbpw = None
+    dbuser = None
+    # Get username and password by parsing authentication XML file
+    authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+    authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+    for entry in authenticationList:
+        if entry.attributes["name"].value == connName:
+            parameters = entry.getElementsByTagName("parameter")
+            # Set username and password from authentication parameters
+            for parameter in parameters:
+                if parameter.attributes["name"].value == "user":
+                    dbuser = parameter.attributes["value"].value
+                elif parameter.attributes["name"].value == "password":
+                    dbpw = parameter.attributes["value"].value
+    dbstring="oracle://ATLAS_COOLPROD;schema="+accountName+";dbname="+schemaName+";user="+dbuser+";password="+dbpw
+    #olddbstring="oracle://ATLAS_COOLPROD;schema="+accountName+";dbname="+schemaName+";user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
+
     try:
         db=dbSvc.openDatabase(dbstring,False)
     except Exception,e:
@@ -449,7 +469,27 @@ def readLhcFillNumber(run):
     iovrange = IOVRange(starttime = startTime, endtime = endTime)
 
     lhcfolder = '/LHC/DCS/FILLSTATE'
-    dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_DCS;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+    # Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+    # see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+    connName="oracle://ATLAS_COOLPROD/ATLAS_COOLOFL_DCS" # the old online one: ATLAS_COOLONL_DCS is not in this file 
+    dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+    dbpw = None
+    dbuser = None
+    # Get username and password by parsing authentication XML file
+    authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+    authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+    for entry in authenticationList:
+        if entry.attributes["name"].value == connName:
+            parameters = entry.getElementsByTagName("parameter")
+            # Set username and password from authentication parameters
+            for parameter in parameters:
+                if parameter.attributes["name"].value == "user":
+                    dbuser = parameter.attributes["value"].value
+                elif parameter.attributes["name"].value == "password":
+                    dbpw = parameter.attributes["value"].value
+    dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLOFL_DCS;dbname=COMP200;user="+dbuser+";password="+dbpw
+    #olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_DCS;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
+
     try:
         dbSvc=cool.DatabaseSvcFactory.databaseService()
         db=dbSvc.openDatabase(dbstring,False)
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/ReadPbmCounters.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/ReadPbmCounters.py
index 13cd7c051a0d..ec9753d2a50c 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/ReadPbmCounters.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/ReadPbmCounters.py
@@ -65,7 +65,26 @@ if (run == -1 or len(lbList) == 0) :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 
 try:
     db=dbSvc.openDatabase(dbstring,False)
@@ -147,7 +166,28 @@ db.closeDatabase()
 ####################################
 # < --
 # now read further trigger counters
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=MONP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=MONP200;user="+dbuser+";password="+dbpw
+#dear user - why not dbname=COMP200? 
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=MONP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 #dbstring = "TRIG_PIT/MONP200"
 try:
     db=dbSvc.openDatabase(dbstring,False)
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/check_ctp_deadtime.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/check_ctp_deadtime.py
index dee806db49a9..dc5fd94ad9bc 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/check_ctp_deadtime.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/check_ctp_deadtime.py
@@ -39,7 +39,26 @@ if (run == -1 or inFile == '') :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 
 try:
     db=dbSvc.openDatabase(dbstring,False)
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_livetime.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_livetime.py
index f0c8498ff371..ea7f9c4ff4eb 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_livetime.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_livetime.py
@@ -47,7 +47,26 @@ if (run == -1) :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 
 try:
     db=dbSvc.openDatabase(dbstring,False)
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates.py
index 7317016330cf..b4e1ac5f3d82 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates.py
@@ -100,7 +100,26 @@ if printNumbers and printRates :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 #dbstring="sqlite://;schema=/afs/cern.ch/user/b/berge/trash/ctp.LBData.1190647872.sqlitefile.db;dbname=L1CTCOOL"
 
 try:
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates_get_lumi.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates_get_lumi.py
index 0cd70e611725..540d7c073759 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates_get_lumi.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/cool_read_lvl1rates_get_lumi.py
@@ -103,7 +103,26 @@ if printNumbers and printRates :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 #dbstring="sqlite://;schema=/afs/cern.ch/user/b/berge/trash/ctp.LBData.1190647872.sqlitefile.db;dbname=L1CTCOOL"
 
 try:
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/fillLVL1histograms.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/fillLVL1histograms.py
index 193e730c7e72..4278eab36e1a 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/fillLVL1histograms.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/fillLVL1histograms.py
@@ -31,7 +31,26 @@ print
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 
 try:
     db=dbSvc.openDatabase(dbstring,False)
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/l1ctpy.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/l1ctpy.py
index b81bdfec0e14..9bc4efc00f66 100644
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/l1ctpy.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/l1ctpy.py
@@ -19,8 +19,26 @@ ORBIT_FREQUENCY = 40.0790e6 / 3564.
 #+================================================================
 
 _COOLDBOWNER='' 
-
-_COOLDB="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=DBNAME;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=DBNAME;user="+dbuser+";password="+dbpw
+#old_COOLDB="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=DBNAME;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 
 def get_dbid_MONP(owner=False):
    if owner:
@@ -38,7 +56,26 @@ def get_dbid_COMP(owner=False):
    
 
 def get_dbid_TDAQ_COMP(owner=False):
-   _COOLDB="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TDAQ;dbname=DBNAME;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+   # Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+   # see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+   connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+   dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+   dbpw = None
+   dbuser = None
+   # Get username and password by parsing authentication XML file
+   authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+   authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+   for entry in authenticationList:
+      if entry.attributes["name"].value == connName:
+         parameters = entry.getElementsByTagName("parameter")
+         # Set username and password from authentication parameters
+         for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+               dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+               dbpw = parameter.attributes["value"].value
+   _COOLDB="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=DBNAME;user="+dbuser+";password="+dbpw
+   #old_COOLDB="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TDAQ;dbname=DBNAME;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
    if owner:
        print "NO OWNER ACCOUNT IMPLEMENTED"
        return _COOLDBOWNER.replace("DBNAME","COMP200")
diff --git a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/read_bunchgroups.py b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/read_bunchgroups.py
index 9e046a1044f4..18f816658041 100755
--- a/Trigger/TrigT1/TrigT1CTMonitoring/scripts/read_bunchgroups.py
+++ b/Trigger/TrigT1/TrigT1CTMonitoring/scripts/read_bunchgroups.py
@@ -44,7 +44,26 @@ if (run == -1) :
 
 # get database service and open database
 dbSvc=cool.DatabaseSvcFactory.databaseService()
-dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=COOLRED4PRO"
+# Get user and passwd from coral auth file - see: https://its.cern.ch/jira/browse/ATR-25572
+# see this package in case the following doesn't work for you: Database/ConnectionManagement/AtlasAuthentication/data/dblookup.xml
+connName="oracle://ATLAS_COOLPROD/ATLAS_COOLONL_TRIGGER" # aka. schema
+dbauthPath=os.environ.get('CORAL_AUTH_PATH')
+dbpw = None
+dbuser = None
+# Get username and password by parsing authentication XML file
+authenticationXmlDoc = minidom.parse(dbauthPath + "authentication.xml")
+authenticationList = authenticationXmlDoc.getElementsByTagName("connection")
+for entry in authenticationList:
+    if entry.attributes["name"].value == connName:
+        parameters = entry.getElementsByTagName("parameter")
+        # Set username and password from authentication parameters
+        for parameter in parameters:
+            if parameter.attributes["name"].value == "user":
+                dbuser = parameter.attributes["value"].value
+            elif parameter.attributes["name"].value == "password":
+                dbpw = parameter.attributes["value"].value
+dbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user="+dbuser+";password="+dbpw
+#olddbstring="oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=COMP200;user=ATLAS_COOL_READER;password=PAssWDusedTObeHEREinPLAINtext"
 #dbstring="sqlite://;schema=/afs/cern.ch/user/b/berge/trash/ctp.LBData.1190647872.sqlitefile.db;dbname=L1CTCOOL"
 
 try:
-- 
GitLab