def doManifestLogFile(action): """ do manifest log file """ service = request.params.get('service', '') package = request.params.get('package', '') manifest = request.params.get('manifest', 'active') if (service == '' or package == ''): c.errorMsg = 'missing service or package parameter from request' c.errorCode = Errors.LOG_PARAM_REQUIRED return render('/derived/error.html') print 'service/package/manifest ', service, package, manifest packagePathStr = packagePath(service, package, manifest) print 'package path ', packagePathStr pkgInit = PkgInitConfig(service, package, manifest) pkgConfig = pkgInit.getConfigs() if not pkgConfig: c.errorMsg = 'cronus.ini does not exist, view log needs cronus.ini to know log location, please check your cronus package to make sure cronus.ini exist and have property logAppDir' c.errorCode = Errors.CRONUS_INI_EMPTY_NOT_FOUND return render('/derived/error.html') print '*** packageConfig ', pkgConfig manifestFileName = pkgConfig['logManifestFile'] if (action == 'download'): return downloadFile(os.path.join(packagePathStr, manifestFileName)) if (action == 'tail'): lines = request.params.get('size', '100') return tailFile(os.path.join(packagePathStr, manifestFileName), lines) if (action == 'list'): return manifestFileName
def doAppLogFile(action): """ listAppLog """ service = request.params.get('service', '') package = request.params.get('package', '') manifest = request.params.get('manifest', 'active') if (service == '' or package == ''): c.errorMsg = 'missing service or package parameter from request' c.errorCode = Errors.LOG_PARAM_REQUIRED return render('/derived/error.html') packagePathStr = packagePath(service, manifest, package) if (not os.path.isdir(packagePathStr)): return ModulelogController.listManifests(service) LOG.info('In ModuleLogController doAppLogFile ' + packagePathStr) pkgInit = PkgInitConfig(service, manifest, package) pkgConfig = pkgInit.getConfigs() if not pkgConfig: c.errorMsg = 'cronus.ini does not exist, view log needs cronus.ini to know log location, please check your cronus package to make sure cronus.ini exist and have property logAppDir' c.errorCode = Errors.CRONUS_INI_EMPTY_NOT_FOUND return render('/derived/error.html') logAppDirList = pkgConfig['logAppDir'] dirName = request.params.get('dirName', '') fileName = request.params.get('fileName', '') if (action == 'list'): if (fileName != '' and dirName != ''): dirName = os.path.join(dirName, fileName) if (dirName != ''): return ModulelogController.listAppLogDir( service, manifest, package, dirName, os.path.join(packagePathStr, dirName)) else: return ModulelogController.listAllAppLogDir( service, manifest, package, dirName, packagePathStr, logAppDirList) if (dirName == '' or fileName == ''): c.errorMsg = 'tail/download App log requires dirName & FileName params missing' c.errorCode = Errors.NOT_ENOUGH_PARAMS return render('/derived/error.html') if (action == 'tail'): lines = request.params.get('size', '100') return tailFile(os.path.join(packagePathStr, dirName, fileName), lines) if (action == 'download'): return downloadFile(os.path.join(packagePathStr, dirName, fileName))
def doAppLogFile(action): """ listAppLog """ service = request.params.get('service', '') package = request.params.get('package', '') manifest = request.params.get('manifest', 'active') if (service == '' or package == ''): c.errorMsg = 'missing service or package parameter from request' c.errorCode = Errors.LOG_PARAM_REQUIRED return render('/derived/error.html') packagePathStr = packagePath(service, manifest, package) if (not os.path.isdir(packagePathStr)): return ModulelogController.listManifests(service) LOG.info('In ModuleLogController doAppLogFile ' + packagePathStr) pkgInit = PkgInitConfig(service, manifest, package) pkgConfig = pkgInit.getConfigs() if not pkgConfig: c.errorMsg = 'cronus.ini does not exist, view log needs cronus.ini to know log location, please check your cronus package to make sure cronus.ini exist and have property logAppDir' c.errorCode = Errors.CRONUS_INI_EMPTY_NOT_FOUND return render('/derived/error.html') logAppDirList = pkgConfig['logAppDir'] dirName = request.params.get('dirName', '') fileName = request.params.get('fileName', '') if (action == 'list'): if (fileName != '' and dirName != ''): dirName = os.path.join(dirName, fileName) if (dirName != ''): return ModulelogController.listAppLogDir(service, manifest, package, dirName, os.path.join(packagePathStr, dirName)) else: return ModulelogController.listAllAppLogDir(service, manifest, package, dirName, packagePathStr, logAppDirList) if (dirName == '' or fileName == ''): c.errorMsg = 'tail/download App log requires dirName & FileName params missing' c.errorCode = Errors.NOT_ENOUGH_PARAMS return render('/derived/error.html') if (action == 'tail'): lines = request.params.get('size', '100') return tailFile(os.path.join(packagePathStr, dirName, fileName), lines) if (action == 'download'): return downloadFile(os.path.join(packagePathStr, dirName, fileName))
def tailAgentLog(self): """ show log file """ lines = '100' if len(request.params) > 0: lines = request.params.get('size', '100') return tailFile('logs/agent.log', lines)