Skip to content

Commit

Permalink
Merge pull request Katello#87 from thomasmckay/import-server
Browse files Browse the repository at this point in the history
retrieve cli arg params properly
  • Loading branch information
thomasmckay committed May 27, 2015
2 parents 17561af + 1e44495 commit 7b235cf
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/hammer_cli_csv/import.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class ImportCommand < HammerCLI::Apipie::Command

option %w(-v --verbose), :flag, 'be verbose'
option %w(--threads), 'THREAD_COUNT', 'Number of threads to hammer with', :default => 1
option %w(--server), 'SERVER', 'Server URL'
option %w(-u --username), 'USERNAME', 'Username to access server'
option %w(-p --password), 'PASSWORD', 'Password to access server'
option '--dir', 'DIRECTORY', 'directory to import from'

RESOURCES = %w( organizations locations puppet_environments operating_systems
Expand All @@ -34,12 +31,8 @@ class ImportCommand < HammerCLI::Apipie::Command
end

def execute
@api = ApipieBindings::API.new({
:uri => option_server || HammerCLI::Settings.get(:csv, :host),
:username => option_username || HammerCLI::Settings.get(:csv, :username),
:password => option_password || HammerCLI::Settings.get(:csv, :password),
:api_version => 2
})
@api = ApipieBindings::API.new({:uri => get_option(:host), :username => get_option(:username),
:password => get_option(:password), :api_version => 2})

# Swing the hammers
RESOURCES.each do |resource|
Expand Down Expand Up @@ -72,6 +65,15 @@ def hammer_resource(resource)
args += %W( --threads #{option_threads} )
hammer.run(args)
end

private

def get_option(name)
HammerCLI::Settings.settings[:_params][name] ||
HammerCLI::Settings.get(:csv, name) ||
HammerCLI::Settings.get(:katello, name) ||
HammerCLI::Settings.get(:foreman, name)
end
end
end
end

0 comments on commit 7b235cf

Please sign in to comment.