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/export.rb
1 1
module HammerCLICsv
2 2
  class CsvCommand
3 3
    class ExportCommand < HammerCLI::Apipie::Command
4
      include ::HammerCLICsv::Utils::Config
5

  
4 6
      command_name 'export'
5 7
      desc         'export into directory'
6 8

  
......
30 32
      end
31 33

  
32 34
      def execute
33
        @server = (HammerCLI::Settings.settings[:_params] &&
34
                   HammerCLI::Settings.settings[:_params][:host]) ||
35
          HammerCLI::Settings.get(:csv, :host) ||
36
          HammerCLI::Settings.get(:katello, :host) ||
37
          HammerCLI::Settings.get(:foreman, :host)
38
        @username = (HammerCLI::Settings.settings[:_params] &&
39
                     HammerCLI::Settings.settings[:_params][:username]) ||
40
          HammerCLI::Settings.get(:csv, :username) ||
41
          HammerCLI::Settings.get(:katello, :username) ||
42
          HammerCLI::Settings.get(:foreman, :username)
43
        @password = (HammerCLI::Settings.settings[:_params] &&
44
                     HammerCLI::Settings.settings[:_params][:password]) ||
45
          HammerCLI::Settings.get(:csv, :password) ||
46
          HammerCLI::Settings.get(:katello, :password) ||
47
          HammerCLI::Settings.get(:foreman, :password)
48

  
49
        @server_status = check_server_status(@server, @username, @password)
50

  
51
        if @server_status['release'] == 'Headpin'
52
          @headpin = HeadpinApi.new({
53
                                      :server => @server,
54
                                      :username => @username,
55
                                      :password => @password
56
                                    })
57
          skipped_resources = %w( settings locations puppet_environments operating_systems
58
                                  domains architectures partition_tables lifecycle_environments
59
                                  provisioning_templates
60
                                  hosts reports )
61
          skipped_resources += %w( subscriptions roles users )  # TODO: not implemented yet
62
        else
63
          @api = ApipieBindings::API.new({
64
                                           :uri => @server,
65
                                           :username => @username,
66
                                           :password => @password,
67
                                           :api_version => 2
68
                                         })
69
          skipped_resources = (RESOURCES - SUPPORTED_RESOURCES)
70
        end
35
        @api = api_connection
36
        skipped_resources = (RESOURCES - SUPPORTED_RESOURCES)
71 37

  
72
        # Swing the hammers
73 38
        (RESOURCES - skipped_resources).each do |resource|
74 39
          hammer_resource(resource)
75 40
        end

Also available in: Unified diff