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/puppet_environments.rb
7 7
      ORGANIZATIONS = 'Organizations'
8 8
      LOCATIONS = 'Locations'
9 9

  
10
      def export
11
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
12
          csv << [NAME, ORGANIZATIONS, LOCATIONS]
13
          @api.resource(:environments).call(:index, {:per_page => 999999})['results'].each do |environment|
14
            environment = @api.resource(:environments).call(:show, {:id => environment['id']})
15
            name = environment['name']
16
            organizations = export_column(environment, 'organizations', 'name')
17
            locations = export_column(environment, 'locations', 'name')
18
            csv << [name, organizations, locations]
19
          end
10
      def export(csv)
11
        csv << [NAME, ORGANIZATIONS, LOCATIONS]
12
        @api.resource(:environments).call(:index, {:per_page => 999999})['results'].each do |environment|
13
          environment = @api.resource(:environments).call(:show, {:id => environment['id']})
14
          name = environment['name']
15
          organizations = export_column(environment, 'organizations', 'name')
16
          locations = export_column(environment, 'locations', 'name')
17
          csv << [name, organizations, locations]
20 18
        end
21 19
      end
22 20

  

Also available in: Unified diff