Project

General

Profile

Revision f5d21adb

Added by Thomas McKay over 5 years ago

fixes #15581 - configuration based on foreman stanza

View differences:

lib/hammer_cli_csv/import.rb
3 3
module HammerCLICsv
4 4
  class CsvCommand
5 5
    class ImportCommand < HammerCLI::Apipie::Command
6
      include ::HammerCLICsv::Utils::Config
7

  
6 8
      command_name 'import'
7 9
      desc         'import by directory'
8 10

  
......
35 37
      end
36 38

  
37 39
      def execute
38
        @server = (HammerCLI::Settings.settings[:_params] &&
39
                   HammerCLI::Settings.settings[:_params][:host]) ||
40
          HammerCLI::Settings.get(:csv, :host) ||
41
          HammerCLI::Settings.get(:katello, :host) ||
42
          HammerCLI::Settings.get(:foreman, :host)
43
        @username = (HammerCLI::Settings.settings[:_params] &&
44
                     HammerCLI::Settings.settings[:_params][:username]) ||
45
          HammerCLI::Settings.get(:csv, :username) ||
46
          HammerCLI::Settings.get(:katello, :username) ||
47
          HammerCLI::Settings.get(:foreman, :username)
48
        @password = (HammerCLI::Settings.settings[:_params] &&
49
                     HammerCLI::Settings.settings[:_params][:password]) ||
50
          HammerCLI::Settings.get(:csv, :password) ||
51
          HammerCLI::Settings.get(:katello, :password) ||
52
          HammerCLI::Settings.get(:foreman, :password)
53
        @api = ApipieBindings::API.new({:uri => @server, :username => @username,
54
                                        :password => @password, :api_version => 2})
40
        @api = api_connection
55 41

  
56 42
        resources_specified = RESOURCES.collect do |resource|
57 43
          resource if self.send("option_#{resource}") || ARGV.include?('--' + resource.gsub('_', '-'))
......
69 55
      def hammer(context = nil)
70 56
        context ||= {
71 57
          :interactive => false,
72
          :username => 'admin', # TODO: this needs to come from config/settings
73
          :password => 'changeme' # TODO: this needs to come from config/settings
58
          :username => @username,
59
          :password => @password
74 60
        }
75 61

  
76 62
        HammerCLI::MainCommand.new('', context)

Also available in: Unified diff