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/domains.rb
12 12

  
13 13
      SEPARATOR = ' = '
14 14

  
15
      def export
16
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
17
          csv << [NAME, ORGANIZATIONS, LOCATIONS, DESCRIPTION, SMART_PROXY, PARAMETERS]
18
          search_options = {:per_page => 999999}
19
          search_options['search'] = "organization=\"#{option_organization}\"" if option_organization
20
          @api.resource(:domains).call(:index, search_options)['results'].each do |domain|
21
            domain = @api.resource(:domains).call(:show, {'id' => domain['id']})
22
            raise "Domain 'id=#{domain['id']}' not found" if !domain || domain.empty?
23

  
24
            name = domain['name']
25
            organizations = option_organization ? option_organization : export_column(domain, 'organizations', 'name')
26
            locations = export_column(domain, 'locations', 'name')
27
            description = domain['fullname']
28
            capsule = foreman_smart_proxy(:id => domain['dns_id'])
29
            parameters = export_parameters(domain['parameters'])
30
            csv << [name, organizations, locations, description, capsule, parameters]
31
          end
15
      def export(csv)
16
        csv << [NAME, ORGANIZATIONS, LOCATIONS, DESCRIPTION, SMART_PROXY, PARAMETERS]
17
        search_options = {:per_page => 999999}
18
        search_options['search'] = "organization=\"#{option_organization}\"" if option_organization
19
        @api.resource(:domains).call(:index, search_options)['results'].each do |domain|
20
          domain = @api.resource(:domains).call(:show, {'id' => domain['id']})
21
          raise "Domain 'id=#{domain['id']}' not found" if !domain || domain.empty?
22

  
23
          name = domain['name']
24
          organizations = option_organization ? option_organization : export_column(domain, 'organizations', 'name')
25
          locations = export_column(domain, 'locations', 'name')
26
          description = domain['fullname']
27
          capsule = foreman_smart_proxy(:id => domain['dns_id'])
28
          parameters = export_parameters(domain['parameters'])
29
          csv << [name, organizations, locations, description, capsule, parameters]
32 30
        end
33 31
      end
34 32

  

Also available in: Unified diff