Project

General

Profile

« Previous | Next » 

Revision f04d61a8

Added by Thomas McKay over 7 years ago

fixes #15310 - export Red Hat subscriptions as comments

View differences:

lib/hammer_cli_csv/subscriptions.rb
csv << [NAME, ORGANIZATION, MANIFEST, CONTENT_SET, ARCH, RELEASE]
@api.resource(:organizations).call(:index, {:per_page => 999999})['results'].each do |organization|
next if option_organization && organization['name'] != option_organization
export_manifest(csv, organization)
@api.resource(:products).call(:index, {
'per_page' => 999999,
'organization_id' => organization['id'],
......
end
end
def export_manifest(csv, organization)
@api.resource(:subscriptions).call(:index, {
'per_page' => 999999,
'organization_id' => organization['id']
})['results'].each do |subscription|
next if subscription['product_id'].to_i != 0 # Red Hat subs do not have number SKU
details = "#{subscription['quantity']}|#{subscription['product_id']}|" \
"#{subscription['name']}|" \
"#{subscription['contract_number']}|#{subscription['account_number']}"
csv << ["# Manifest Subscription", organization['name'], nil, nil, nil, details]
end
end
def import
thread_import do |line|
if line[MANIFEST] && !line[MANIFEST].empty?

Also available in: Unified diff