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/operating_systems.rb
13 13
      PROVISIONING_TEMPLATES = 'Provisioning Templates'
14 14
      PARAMETERS = 'Parameters'
15 15

  
16
      def export
17
        CSV.open(option_file || '/dev/stdout', 'wb', {:force_quotes => true}) do |csv|
18
          csv << [NAME, DESCRIPTION, FAMILY, PASSWORD_HASH, PARTITION_TABLES, ARCHITECTURES, MEDIA,
19
                  PROVISIONING_TEMPLATES, PARAMETERS]
20
          @api.resource(:operatingsystems).call(:index, {:per_page => 999999})['results'].each do |operatingsystem_id|
21
            operatingsystem = @api.resource(:operatingsystems).call(:show, {:id => operatingsystem_id['id']})
22
            name = build_os_name(operatingsystem['name'], operatingsystem['major'], operatingsystem['minor'])
23
            description = operatingsystem['description']
24
            family = operatingsystem['family']
25
            password_hash = operatingsystem['password_hash']
26
            partition_tables = export_column(operatingsystem, 'ptables', 'name')
27
            architectures = export_column(operatingsystem, 'architectures', 'name')
28
            media = export_column(operatingsystem, 'media', 'name')
29
            partition_tables = export_column(operatingsystem, 'ptables', 'name')
30
            parameters = export_column(operatingsystem, 'parameters') do |parameter|
31
              "#{parameter['name']}|#{parameter['value']}"
32
            end
33
            csv << [name, description, family, password_hash, partition_tables, architectures,
34
                    media, partition_tables, parameters]
16
      def export(csv)
17
        csv << [NAME, DESCRIPTION, FAMILY, PASSWORD_HASH, PARTITION_TABLES, ARCHITECTURES, MEDIA,
18
                PROVISIONING_TEMPLATES, PARAMETERS]
19
        @api.resource(:operatingsystems).call(:index, {:per_page => 999999})['results'].each do |operatingsystem_id|
20
          operatingsystem = @api.resource(:operatingsystems).call(:show, {:id => operatingsystem_id['id']})
21
          name = build_os_name(operatingsystem['name'], operatingsystem['major'], operatingsystem['minor'])
22
          description = operatingsystem['description']
23
          family = operatingsystem['family']
24
          password_hash = operatingsystem['password_hash']
25
          partition_tables = export_column(operatingsystem, 'ptables', 'name')
26
          architectures = export_column(operatingsystem, 'architectures', 'name')
27
          media = export_column(operatingsystem, 'media', 'name')
28
          partition_tables = export_column(operatingsystem, 'ptables', 'name')
29
          parameters = export_column(operatingsystem, 'parameters') do |parameter|
30
            "#{parameter['name']}|#{parameter['value']}"
35 31
          end
32
          csv << [name, description, family, password_hash, partition_tables, architectures,
33
                  media, partition_tables, parameters]
36 34
        end
37 35
      end
38 36

  

Also available in: Unified diff