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/base.rb
8 8
# rubocop:disable ClassLength
9 9
module HammerCLICsv
10 10
  class BaseCommand < HammerCLI::Apipie::Command
11
    include ::HammerCLICsv::Utils::Config
12

  
11 13
    option %w(-v --verbose), :flag, 'be verbose'
12 14
    option %w(--threads), 'THREAD_COUNT', 'Number of threads to hammer with',
13 15
           :default => 1, :hidden => true
......
42 44
    end
43 45

  
44 46
    def execute
45
      @server = (HammerCLI::Settings.settings[:_params] &&
46
                 HammerCLI::Settings.settings[:_params][:host]) ||
47
        HammerCLI::Settings.get(:csv, :host) ||
48
        HammerCLI::Settings.get(:katello, :host) ||
49
        HammerCLI::Settings.get(:foreman, :host)
50
      @username = (HammerCLI::Settings.settings[:_params] &&
51
                   HammerCLI::Settings.settings[:_params][:username]) ||
52
        HammerCLI::Settings.get(:csv, :username) ||
53
        HammerCLI::Settings.get(:katello, :username) ||
54
        HammerCLI::Settings.get(:foreman, :username)
55
      @password = (HammerCLI::Settings.settings[:_params] &&
56
                   HammerCLI::Settings.settings[:_params][:password]) ||
57
        HammerCLI::Settings.get(:csv, :password) ||
58
        HammerCLI::Settings.get(:katello, :password) ||
59
        HammerCLI::Settings.get(:foreman, :password)
60

  
47
      @api = api_connection
61 48
      @server_status = check_server_status(@server, @username, @password)
62 49

  
63
      if @server_status['release'] == 'Headpin'
64
        @headpin = HeadpinApi.new({
65
                                    :server => @server,
66
                                    :username => @username,
67
                                    :password => @password
68
                                  })
69
      else
70
        @api = ApipieBindings::API.new({
71
                                         :uri => @server,
72
                                         :username => @username,
73
                                         :password => @password,
74
                                         :api_version => 2
75
                                       })
76
      end
77

  
78 50
      if option_export?
79 51
        if option_file
80 52
          CSV.open(option_file, 'wb', {:force_quotes => false}) do |csv|

Also available in: Unified diff