def initializeHandler(cls, serviceInfo): multiPath = PathFinder.getDatabaseSection("Accounting/MultiDB") cls.__acDB = MultiAccountingDB(multiPath, readOnly=True) # Get data location reportSection = serviceInfo["serviceSectionPath"] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/accountingGraphs") dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath("%s/%s" % (gConfig.getValue( "/LocalSite/InstancePath", rootPath), dataPath)) gLogger.info("Data will be written into %s" % dataPath) mkDir(dataPath) try: testFile = "%s/acc.jarl.test" % dataPath with open(testFile, "w"): pass os.unlink(testFile) except IOError: gLogger.fatal("Can't write to %s" % dataPath) return S_ERROR("Data location is not writable") gDataCache.setGraphsLocation(dataPath) gMonitor.registerActivity("plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM) gMonitor.registerActivity("reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM) return S_OK()
def initializeHandler(cls, serviceInfo): try: result = ObjectLoader().loadObject( "MonitoringSystem.DB.MonitoringDB", "MonitoringDB") if not result["OK"]: return result cls.__db = result["Value"]() except RuntimeError as excp: return S_ERROR("Can't connect to DB: %s" % excp) reportSection = serviceInfo["serviceSectionPath"] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/monitoringPlots") gLogger.info("Data will be written into %s" % dataPath) mkDir(dataPath) try: testFile = "%s/moni.plot.test" % dataPath with open(testFile, "w") as _: os.unlink(testFile) except IOError as err: gLogger.fatal("Can't write to %s" % dataPath, err) return S_ERROR("Data location is not writable: %s" % repr(err)) gDataCache.setGraphsLocation(dataPath) return S_OK()
def initializeHandler( cls, serviceInfo ): cls.__db = MonitoringDB() reportSection = serviceInfo[ 'serviceSectionPath' ] dataPath = gConfig.getValue( "%s/DataLocation" % reportSection, "data/monitoringPlots" ) gLogger.info( "Data will be written into %s" % dataPath ) mkDir( dataPath ) try: testFile = "%s/moni.plot.test" % dataPath with open( testFile, "w" ) as _fd: os.unlink( testFile ) except IOError as err: gLogger.fatal( "Can't write to %s" % dataPath, err ) return S_ERROR( "Data location is not writable: %s" % repr( err ) ) gDataCache.setGraphsLocation( dataPath ) return S_OK()
def initializeHandler(cls, serviceInfo): cls.__db = MonitoringDB() reportSection = serviceInfo['serviceSectionPath'] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/monitoringPlots") gLogger.info("Data will be written into %s" % dataPath) mkDir(dataPath) try: testFile = "%s/moni.plot.test" % dataPath with open(testFile, "w") as _: os.unlink(testFile) except IOError as err: gLogger.fatal("Can't write to %s" % dataPath, err) return S_ERROR("Data location is not writable: %s" % repr(err)) gDataCache.setGraphsLocation(dataPath) return S_OK()
def initializeHandler(cls, serviceInfo): multiPath = PathFinder.getDatabaseSection("Accounting/MultiDB") cls.__acDB = MultiAccountingDB(multiPath, readOnly=True) # Get data location reportSection = serviceInfo["serviceSectionPath"] dataPath = gConfig.getValue("%s/DataLocation" % reportSection, "data/accountingGraphs") dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath(f"{rootPath}/{dataPath}") gLogger.info(f"Data will be written into {dataPath}") mkDir(dataPath) try: testFile = "%s/acc.jarl.test" % dataPath with open(testFile, "w"): pass os.unlink(testFile) except IOError: gLogger.fatal("Can't write to %s" % dataPath) return S_ERROR("Data location is not writable") gDataCache.setGraphsLocation(dataPath) return S_OK()
def initializeHandler( cls, serviceInfo ): multiPath = PathFinder.getDatabaseSection( "Accounting/MultiDB" ) cls.__acDB = MultiAccountingDB( multiPath, readOnly = True ) #Get data location reportSection = serviceInfo[ 'serviceSectionPath' ] dataPath = gConfig.getValue( "%s/DataLocation" % reportSection, "data/accountingGraphs" ) dataPath = dataPath.strip() if "/" != dataPath[0]: dataPath = os.path.realpath( "%s/%s" % ( gConfig.getValue( '/LocalSite/InstancePath', rootPath ), dataPath ) ) gLogger.info( "Data will be written into %s" % dataPath ) mkDir( dataPath ) try: testFile = "%s/acc.jarl.test" % dataPath fd = file( testFile, "w" ) fd.close() os.unlink( testFile ) except IOError: gLogger.fatal( "Can't write to %s" % dataPath ) return S_ERROR( "Data location is not writable" ) gDataCache.setGraphsLocation( dataPath ) gMonitor.registerActivity( "plotsDrawn", "Drawn plot images", "Accounting reports", "plots", gMonitor.OP_SUM ) gMonitor.registerActivity( "reportsRequested", "Generated reports", "Accounting reports", "reports", gMonitor.OP_SUM ) return S_OK()