Project

General

Profile

« Previous | Next » 

Revision f5d21adb

Added by Thomas McKay over 7 years ago

fixes #15581 - configuration based on foreman stanza

View differences:

lib/hammer_cli_csv/import.rb
module HammerCLICsv
class CsvCommand
class ImportCommand < HammerCLI::Apipie::Command
include ::HammerCLICsv::Utils::Config
command_name 'import'
desc 'import by directory'
......
end
def execute
@server = (HammerCLI::Settings.settings[:_params] &&
HammerCLI::Settings.settings[:_params][:host]) ||
HammerCLI::Settings.get(:csv, :host) ||
HammerCLI::Settings.get(:katello, :host) ||
HammerCLI::Settings.get(:foreman, :host)
@username = (HammerCLI::Settings.settings[:_params] &&
HammerCLI::Settings.settings[:_params][:username]) ||
HammerCLI::Settings.get(:csv, :username) ||
HammerCLI::Settings.get(:katello, :username) ||
HammerCLI::Settings.get(:foreman, :username)
@password = (HammerCLI::Settings.settings[:_params] &&
HammerCLI::Settings.settings[:_params][:password]) ||
HammerCLI::Settings.get(:csv, :password) ||
HammerCLI::Settings.get(:katello, :password) ||
HammerCLI::Settings.get(:foreman, :password)
@api = ApipieBindings::API.new({:uri => @server, :username => @username,
:password => @password, :api_version => 2})
@api = api_connection
resources_specified = RESOURCES.collect do |resource|
resource if self.send("option_#{resource}") || ARGV.include?('--' + resource.gsub('_', '-'))
......
def hammer(context = nil)
context ||= {
:interactive => false,
:username => 'admin', # TODO: this needs to come from config/settings
:password => 'changeme' # TODO: this needs to come from config/settings
:username => @username,
:password => @password
}
HammerCLI::MainCommand.new('', context)

Also available in: Unified diff