Project

General

Profile

Revision a77acc4a

Added by Thomas McKay about 9 years ago

a lot of fixes and updates across many resources to match katello updates

View differences:

lib/hammer_cli_csv/import.rb
32 32
      option '--users', 'FILE', 'source to import users'
33 33
      option '--hosts', 'FILE', 'source to import hosts'
34 34
      option '--organizations', 'FILE', 'source to import organizations'
35
      option '--locations', 'FILE', 'source to import locations'
36
      option '--puppet-environments', 'FILE', 'source to puppet environments'
37
      option '--operating-systems', 'FILE', 'source to operating systems'
38
      option '--architectures', 'FILE', 'source to architectures'
39
      option '--domains', 'FILE', 'source to domains'
40
      option '--architectures', 'FILE', 'source to architectures'
41
      option '--partition-tables', 'FILE', 'source to partition-tables'
35 42

  
36 43
      def ctx
37 44
        {
......
54 61
                                       })
55 62

  
56 63
        # Swing the hammers
57
        swing('organizations')
58
        swing('roles')
59
        swing('users')
60
        swing('hosts')
64
        %w( organizations locations roles users puppet_environments operating_systems
65
            hosts domains architectures partition_tables ).each do |resource|
66
          swing(resource)
67
        end
61 68

  
62 69
        HammerCLI::EX_OK
63 70
      end
64 71

  
65 72
      def swing(resource)
66
        options_file = self.send("option_#{resource}")
67
        options_file ||= "#{option_dir}/#{resource}.csv" if option_dir
68
        args = %W{ csv #{resource} --csv-file #{options_file} }
73
        return if !self.send("option_#{resource}") && !option_dir
74
        options_file = self.send("option_#{resource}") || "#{option_dir}/#{resource.sub('_', '-')}.csv"
75
        raise "File for #{resource} '#{options_file}' does not exist" unless File.exists? options_file
76
        args = %W{ csv #{resource.sub('_', '-')} --csv-file #{options_file} }
69 77
        args << '-v' if option_verbose?
70
        hammer.run(args) if File.exists? options_file
78
        hammer.run(args)
71 79
      end
72 80
    end
73 81
  end

Also available in: Unified diff