Project

General

Profile

Revision c4dbc7a3

Added by Thomas McKay over 7 years ago

updates to tests and functionality

+ added export containers
+ export content-view-filters erratum and rpm types
+ 'hammer csv import' now works from --dir https://somewhere
+ 'hammer csv import' tests and fixes

View differences:

lib/hammer_cli_csv/base.rb
27 27
    COUNT = 'Count'
28 28

  
29 29
    def execute
30
      @server = HammerCLI::Settings.settings[:_params][:host] ||
30
      @server = (HammerCLI::Settings.settings[:_params] &&
31
                 HammerCLI::Settings.settings[:_params][:host]) ||
31 32
        HammerCLI::Settings.get(:csv, :host) ||
32 33
        HammerCLI::Settings.get(:katello, :host) ||
33 34
        HammerCLI::Settings.get(:foreman, :host)
34
      @username = HammerCLI::Settings.settings[:_params][:username] ||
35
      @username = (HammerCLI::Settings.settings[:_params] &&
36
                   HammerCLI::Settings.settings[:_params][:username]) ||
35 37
        HammerCLI::Settings.get(:csv, :username) ||
36 38
        HammerCLI::Settings.get(:katello, :username) ||
37 39
        HammerCLI::Settings.get(:foreman, :username)
38
      @password = HammerCLI::Settings.settings[:_params][:password] ||
40
      @password = (HammerCLI::Settings.settings[:_params] &&
41
                   HammerCLI::Settings.settings[:_params][:password]) ||
39 42
        HammerCLI::Settings.get(:csv, :password) ||
40 43
        HammerCLI::Settings.get(:katello, :password) ||
41 44
        HammerCLI::Settings.get(:foreman, :password)
......
714 717
      result
715 718
    end
716 719

  
720
    def foreman_container(options = {})
721
      @containers ||= {}
722

  
723
      if options[:name]
724
        return nil if options[:name].nil? || options[:name].empty?
725
        options[:id] = @containers[options[:name]]
726
        if !options[:id]
727
          container = @api.resource(:containers).call(:index, {
728
                                                       :per_page => 999999,
729
                                                       'search' => "name=\"#{options[:name]}\""
730
                                                     })['results']
731
          raise "Container '#{options[:name]}' not found" if !container || container.empty?
732
          options[:id] = container[0]['id']
733
          @containers[options[:name]] = options[:id]
734
        end
735
        result = options[:id]
736
      else
737
        return nil if options[:id].nil?
738
        options[:name] = @containers.key(options[:id])
739
        if !options[:name]
740
          container = @api.resource(:containers).call(:show, {'id' => options[:id]})
741
          raise "Container 'id=#{options[:id]}' not found" if !container || container.empty?
742
          options[:name] = container['name']
743
          @containers[options[:name]] = options[:id]
744
        end
745
        result = options[:name]
746
      end
747

  
748
      result
749
    end
750

  
751

  
717 752
    def build_os_name(name, major, minor)
718 753
      name += " #{major}" if major && major != ''
719 754
      name += ".#{minor}" if minor && minor != ''

Also available in: Unified diff