Project

General

Profile

Revision f04d61a8

Added by Thomas McKay about 6 years ago

fixes #15310 - export Red Hat subscriptions as comments

View differences:

lib/hammer_cli_csv/subscriptions.rb
15 15
          csv << [NAME, ORGANIZATION, MANIFEST, CONTENT_SET, ARCH, RELEASE]
16 16
          @api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
17 17
            next if option_organization && organization['name'] != option_organization
18
            export_manifest(csv, organization)
18 19
            @api.resource(:products).call(:index, {
19 20
                'per_page' => 999999,
20 21
                'organization_id' => organization['id'],
......
42 43
        end
43 44
      end
44 45

  
46
      def export_manifest(csv, organization)
47
        @api.resource(:subscriptions).call(:index, {
48
            'per_page' => 999999,
49
            'organization_id' => organization['id']
50
        })['results'].each do |subscription|
51
          next if subscription['product_id'].to_i != 0  # Red Hat subs do not have number SKU
52
          details = "#{subscription['quantity']}|#{subscription['product_id']}|" \
53
            "#{subscription['name']}|" \
54
            "#{subscription['contract_number']}|#{subscription['account_number']}"
55
          csv << ["# Manifest Subscription", organization['name'], nil, nil, nil, details]
56
        end
57
      end
58

  
45 59
      def import
46 60
        thread_import do |line|
47 61
          if line[MANIFEST] && !line[MANIFEST].empty?

Also available in: Unified diff