Project

General

Profile

Revision c06f1783

Added by Thomas McKay over 6 years ago

fixes #15743 - import and export of subscriptions one-per-line

View differences:

lib/hammer_cli_csv/installation_media.rb
10 10
      OSFAMILY = 'OS Family'
11 11
      OPERATING_SYSTEMS = 'Operating Systems'
12 12

  
13
      def export
14
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
15
          csv << [NAME, ORGANIZATIONS, LOCATIONS, PATH, OSFAMILY, OPERATING_SYSTEMS]
16
          @api.resource(:media).call(:index, {:per_page => 999999})['results'].each do |medium|
17
            medium = @api.resource(:media).call(:show, :id => medium['id'])
18
            name = medium['name']
19
            organizations = export_column(medium, 'organizations', 'name')
20
            locations = export_column(medium, 'locations', 'name')
21
            count = 1
22
            path = medium['path']
23
            os_family = medium['os_family']
24
            operating_systems = export_column(medium, 'operatingsystems', 'title')
25
            csv << [name, organizations, locations, path, os_family, operating_systems]
26
          end
13
      def export(csv)
14
        csv << [NAME, ORGANIZATIONS, LOCATIONS, PATH, OSFAMILY, OPERATING_SYSTEMS]
15
        @api.resource(:media).call(:index, {:per_page => 999999})['results'].each do |medium|
16
          medium = @api.resource(:media).call(:show, :id => medium['id'])
17
          name = medium['name']
18
          organizations = export_column(medium, 'organizations', 'name')
19
          locations = export_column(medium, 'locations', 'name')
20
          count = 1
21
          path = medium['path']
22
          os_family = medium['os_family']
23
          operating_systems = export_column(medium, 'operatingsystems', 'title')
24
          csv << [name, organizations, locations, path, os_family, operating_systems]
27 25
        end
28 26
      end
29 27

  

Also available in: Unified diff