Class: KPM::DiagnosticFile
- Inherits:
-
Object
- Object
- KPM::DiagnosticFile
- Defined in:
- lib/kpm/diagnostic_file.rb
Constant Summary collapse
- TMP_DIR_PREFIX =
Temporary directory
'killbill-diagnostics-'- TMP_DIR =
Dir.mktmpdir(TMP_DIR_PREFIX)
- TMP_LOGS_DIR =
TMP_DIR + File::Separator + 'logs'
- TENANT_FILE =
'tenant_config.data'- SYSTEM_FILE =
'system_configuration.data'- ACCOUNT_FILE =
'account.data'- TODAY_DATE =
Date.today.strftime('%m-%d-%y')
- ZIP_FILE =
'killbill-diagnostics-' + TODAY_DATE + '.zip'
- ZIP_LOG_FILE =
'logs.zip'
Instance Method Summary collapse
- #export_data(account_id = nil, log_dir = nil) ⇒ Object
-
#initialize(config_file = nil, killbill_api_credentials = nil, killbill_credentials = nil, killbill_url = nil, database_name = nil, database_credentials = nil, database_host = nil, database_port = nil, kaui_web_path = nil, killbill_web_path = nil, bundles_dir = nil, logger = nil) ⇒ DiagnosticFile
constructor
A new instance of DiagnosticFile.
Constructor Details
#initialize(config_file = nil, killbill_api_credentials = nil, killbill_credentials = nil, killbill_url = nil, database_name = nil, database_credentials = nil, database_host = nil, database_port = nil, kaui_web_path = nil, killbill_web_path = nil, bundles_dir = nil, logger = nil) ⇒ DiagnosticFile
Returns a new instance of DiagnosticFile.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/kpm/diagnostic_file.rb', line 26 def initialize(config_file = nil, killbill_api_credentials = nil, killbill_credentials = nil, killbill_url = nil, database_name = nil, database_credentials = nil, database_host = nil, database_port = nil, kaui_web_path = nil, killbill_web_path = nil, bundles_dir = nil, logger = nil) @killbill_api_credentials = killbill_api_credentials @killbill_credentials = killbill_credentials @killbill_url = killbill_url @database_name = database_name @database_credentials = database_credentials @database_host = database_host @database_port = database_port @config_file = config_file @kaui_web_path = kaui_web_path; @killbill_web_path = killbill_web_path; @logger = logger @original_logger_level = logger.level; @catalina_base = nil @bundles_dir = bundles_dir end |
Instance Method Details
#export_data(account_id = nil, log_dir = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/kpm/diagnostic_file.rb', line 45 def export_data(account_id = nil, log_dir = nil) set_config(@config_file) tenant_export_file = get_tenant_config system_export_file = get_system_config account_export_file = get_account_data(account_id) unless account_id.nil? log_files = get_log_files(log_dir) if File.exist?(system_export_file) && File.exist?(tenant_export_file) zip_file_name = TMP_DIR + File::Separator + ZIP_FILE Zip::File.open(zip_file_name, Zip::File::CREATE) do |zipFile| zipFile.add(TENANT_FILE, tenant_export_file) zipFile.add(SYSTEM_FILE, system_export_file) zipFile.add(ACCOUNT_FILE, account_export_file) unless account_id.nil? zipFile.add(ZIP_LOG_FILE, log_files) unless log_files.nil? end @logger.info "\e[32mDiagnostic data exported under #{zip_file_name} \e[0m" else raise Interrupt, 'Account id or configuration file not found' end end |