Exemple #1
0
    def __init__(self, database, dbConfig=None, pool=None, makePool=False):
        """
        initialize the API instance
        - database can be both MySQl or SQLite

        - dbConfig can be a dictionary with the format
           {'dbName':'BossLiteDB',
               'host':'localhost',
               'user':'******',
               'passwd':'BossLitePass',
               'socketFileLocation':'/var/run/mysql/mysql.sock',
               'portNr':'',
               'refreshPeriod' : 4*3600 ,
               'maxConnectionAttempts' : 5,
               'dbWaitingTime' : 10
              }

        Passing only dbConfig, a SafeSession will be used for db connection.
        Passing a pool or setting makePool, a pool of SafeSession (SafePool)
        will be used, enabling a better multithread usage
        """

        if database == "WMCore":
            from ProdCommon.BossLite.API.BossLiteDBWMCore import BossLiteDBWMCore
            self.bossLiteDB = BossLiteDBWMCore(database, dbConfig=dbConfig)
        elif pool is None and makePool == False:
            self.bossLiteDB = BossLiteDB(database, dbConfig=dbConfig)
        else:
            from ProdCommon.BossLite.API.BossLitePoolDB import BossLitePoolDB
            self.bossLiteDB = BossLitePoolDB( database, dbConfig=dbConfig, \
                                              pool=pool )
        self.db = None
Exemple #2
0
#!/usr/bin/env python

from ProdCommon.BossLite.API.BossLiteDB import BossLiteDB
from ProdCommon.BossLite.Monitoring.Monitoring import Monitoring
from ProdAgentDB.Config import defaultConfig as dbConfig

bossSession = BossLiteDB('MySQL', dbConfig)

dbClass = Monitoring(bossSession)

print 'Exit codes per site'

print dbClass.exitCodes()

print ''
print 'Active status'
print dbClass.activeStatus('days', 365, 1228384986)

print ''
print 'Destination'
print dbClass.destination('hours', 12)