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 listAppLogDir(service, manifest, package, shortDirName, dirName): """ listAppLogDir """ LOG.debug('In ApplogController dirName ' + dirName) contentType = request.environ['CONTENT_TYPE'] if (not os.path.exists(dirName)): c.errorMsg = 'App Log directory (%s) missing' % (dirName) c.errorCode = Errors.LOG_APP_DIR_NOT_FOUND return render('/derived/error.html') if (os.path.isfile(dirName)): if contentType == 'text/plain': return downloadFile(dirName) else: return viewFile(dirName) if (os.path.isdir(dirName)): logList = os.listdir(dirName) if contentType == 'application/json': return ApplogController.doJSonStr(logList) else: fullLogList = [] for fileName in logList: logList = ApplogController.getAppLogEntryHtml( service, manifest, package, shortDirName, dirName, fileName) fullLogList.append(logList) c.status = fullLogList c.message = "List Of Files/Directories" + "" c.absolutePath = dirName c.menuTab = 'MENU_TAB_APPLOGS' return render('/derived/appLogDirectory.html')
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 downloadAgentLog(self): """ show log file """ print serviceRootPath() return downloadFile('logs/agent.log')