Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work for 270 #272

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions kpm/lib/kpm/diagnostic_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ class DiagnosticFile
ZIP_LOG_FILE = 'logs.zip'

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,
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
Expand Down Expand Up @@ -109,8 +105,8 @@ def retrieve_account_data(account_id)
@logger.level = Logger::WARN

account = KPM::Account.new(@config_file, @killbill_api_credentials, @killbill_credentials,
@killbill_url, @database_name,
@database_credentials, @database_host, @database_port, nil, @logger)
@killbill_url, nil,
nil, nil, nil, nil, @logger)
export_file = account.export_data(account_id)

final = TMP_DIR + File::Separator + ACCOUNT_FILE
Expand Down
82 changes: 49 additions & 33 deletions kpm/lib/kpm/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ def version
say "KPM version #{KPM::VERSION}"
end

class_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."

class_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'

method_option :force_download,
type: :boolean,
default: false,
Expand Down Expand Up @@ -104,6 +94,14 @@ def cleanup
type: :boolean,
default: true,
desc: 'Validate sha1 sum'
method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'pull_kb_server_war <version>', 'Pulls Kill Bill server war and places it on your machine. If version was not specified it uses the latest released version.'
def pull_kb_server_war(version = 'LATEST')
installer = BaseInstaller.new(logger,
Expand All @@ -121,6 +119,14 @@ def pull_kb_server_war(version = 'LATEST')
say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
end

method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'search_for_kb_server', 'Searches for all versions of Kill Bill server and prints them to the screen.'
def search_for_kb_server
say "Available versions: #{KillbillServerArtifact.versions(KillbillServerArtifact::KILLBILL_ARTIFACT_ID,
Expand Down Expand Up @@ -207,6 +213,14 @@ def install_java_plugin(plugin_key, kb_version = 'LATEST')
type: :boolean,
default: true,
desc: 'Validates sha1 sum'
method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'pull_defaultbundles <kb-version>', 'Pulls the default OSGI bundles and places it on your machine. If the kb-version has been specified, it is used to download the matching platform artifact; if not, it uses the latest released version.'
def pull_defaultbundles(kb_version = 'LATEST')
response = BaseInstaller.new(logger,
Expand All @@ -219,7 +233,14 @@ def pull_defaultbundles(kb_version = 'LATEST')
options[:verify_sha1])
say "Artifact has been retrieved and can be found at path: #{response[:file_path]}", :green
end

method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'search_for_plugins', 'Searches for all available plugins and prints them to the screen.'
def search_for_plugins
all_plugins = KillbillPluginArtifact.versions(options[:overrides], options[:ssl_verify])
Expand Down Expand Up @@ -251,6 +272,14 @@ def search_for_plugins
type: :boolean,
default: true,
desc: 'Validates sha1 sum'
method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'pull_kaui_war <version>', 'Pulls Kaui war and places it on your machine. If version was not specified it uses the latest released version.'
def pull_kaui_war(version = 'LATEST')
response = KauiArtifact.pull(logger,
Expand Down Expand Up @@ -293,6 +322,14 @@ def search_for_kaui
type: :boolean,
default: false,
desc: 'Set the output format as JSON when true'
method_option :overrides,
type: :hash,
default: nil,
desc: "A hashed list of overrides. Available options are 'url', 'repository', 'username', and 'password'."
method_option :ssl_verify,
type: :boolean,
default: true,
desc: 'Set to false to disable SSL Verification.'
desc 'info', 'Describe information about a Kill Bill version'
def info
versions_info = KillbillServerArtifact.info(options[:version],
Expand Down Expand Up @@ -525,22 +562,6 @@ def tenant_config
type: :string,
default: nil,
desc: 'Killbill URL ex. http://127.0.0.1:8080'
method_option :database_name,
type: :string,
default: nil,
desc: 'DB name to connect'
method_option :database_credentials,
type: :array,
default: nil,
desc: 'DB credentials <user> <password>'
method_option :database_host,
type: :string,
default: nil,
desc: 'Database Host name'
method_option :database_port,
type: :string,
default: nil,
desc: 'Database port'
method_option :kaui_web_path,
type: :string,
default: nil,
Expand All @@ -563,17 +584,12 @@ def diagnostic

raise Interrupt, '--killbill_credentials, required format -> <user> <password>' if options[:killbill_credentials] && options[:killbill_credentials].size != 2

raise Interrupt, '--database_credentials, required format -> <user> <password>' if options[:database_credentials] && options[:database_credentials].size != 2

raise Interrupt, '--database_credentials, please provide a valid database name' if options[:database_name] && options[:database_name] == :database_name.to_s

raise Interrupt, '--kaui_web_path, please provide a valid kaui web path ' if options[:kaui_web_path] && options[:kaui_web_path] == :kaui_web_path.to_s

raise Interrupt, '--killbill_web_path, please provide a valid killbill web path' if options[:killbill_web_path] && options[:killbill_web_path] == :killbill_web_path.to_s

diagnostic = KPM::DiagnosticFile.new(options[:config_file], options[:killbill_api_credentials], options[:killbill_credentials],
options[:killbill_url], options[:database_name], options[:database_credentials],
options[:database_host], options[:database_port], options[:kaui_web_path], options[:killbill_web_path], options[:bundles_dir], logger)
options[:killbill_url], options[:kaui_web_path], options[:killbill_web_path], options[:bundles_dir], logger)
diagnostic.export_data(options[:account_export], options[:log_dir])
rescue StandardError => e
logger.error "\e[91;1m#{e.message}\e[0m"
Expand Down
Loading