Revision 4a6b2238
Added by Thomas McKay about 6 years ago
lib/hammer_cli_csv/content_hosts.rb | ||
---|---|---|
101 | 101 |
if host['subscription_facet_attributes'] |
102 | 102 |
subscriptions = @api.resource(:host_subscriptions).call(:index, { |
103 | 103 |
'organization_id' => host['organization_id'], |
104 |
'host_id' => host['id'] |
|
104 |
'host_id' => host['id'], |
|
105 |
'full_results' => true |
|
105 | 106 |
})['results'] |
106 | 107 |
if subscriptions.empty? |
107 | 108 |
%W(#{SUBS_NAME} #{SUBS_TYPE} #{SUBS_QUANTITY} #{SUBS_SKU} #{SUBS_CONTRACT} |
... | ... | |
184 | 185 |
search = namify(line[SEARCH], number) |
185 | 186 |
@api.resource(:hosts).call(:index, { |
186 | 187 |
'organization_id' => foreman_organization(:name => line[ORGANIZATION]), |
187 |
'search' => search |
|
188 |
'search' => search, |
|
189 |
'per_page' => 999999 |
|
188 | 190 |
})['results'].each do |host| |
189 | 191 |
if host['subscription_facet_attributes'] |
190 | 192 |
create_named_from_csv(host['name'], line) |
... | ... | |
340 | 342 |
|
341 | 343 |
def update_subscriptions(host, line, remove_existing) |
342 | 344 |
existing_subscriptions = @api.resource(:host_subscriptions).call(:index, { |
343 |
'host_id' => host['id'] |
|
345 |
'host_id' => host['id'], |
|
346 |
'full_results' => true |
|
344 | 347 |
})['results'] |
345 | 348 |
if remove_existing && existing_subscriptions.length != 0 |
346 | 349 |
existing_subscriptions.map! do |existing_subscription| |
... | ... | |
445 | 448 |
})['results'].each do |organization| |
446 | 449 |
next if option_organization && organization['name'] != option_organization |
447 | 450 |
|
448 |
@api.resource(:hosts).call(:index, { |
|
449 |
'full_results' => true,
|
|
451 |
total = @api.resource(:hosts).call(:index, {
|
|
452 |
'organization_id' => foreman_organization(:name => organization['name']),
|
|
450 | 453 |
'search' => option_search, |
451 |
'organization_id' => foreman_organization(:name => organization['name']) |
|
452 |
})['results'].each do |host| |
|
453 |
host = @api.resource(:hosts).call(:show, { |
|
454 |
'id' => host['id'] |
|
455 |
}) |
|
456 |
host['facts'] ||= {} |
|
457 |
unless host['subscription_facet_attributes'].nil? |
|
458 |
if host['subscription_facet_attributes']['virtual_guests'].empty? |
|
459 |
hosts.push(host) |
|
460 |
else |
|
461 |
hypervisors.push(host) |
|
454 |
'per_page' => 1 |
|
455 |
})['total'].to_i |
|
456 |
(total / 20 + 1).to_i.times do |page| |
|
457 |
@api.resource(:hosts).call(:index, { |
|
458 |
'page' => page + 1, |
|
459 |
'per_page' => 20, |
|
460 |
'search' => option_search, |
|
461 |
'organization_id' => foreman_organization(:name => organization['name']) |
|
462 |
})['results'].each do |host| |
|
463 |
host = @api.resource(:hosts).call(:show, { |
|
464 |
'id' => host['id'] |
|
465 |
}) |
|
466 |
host['facts'] ||= {} |
|
467 |
unless host['subscription_facet_attributes'].nil? |
|
468 |
if host['subscription_facet_attributes']['virtual_guests'].empty? |
|
469 |
hosts.push(host) |
|
470 |
else |
|
471 |
hypervisors.push(host) |
|
472 |
end |
|
462 | 473 |
end |
463 | 474 |
end |
464 | 475 |
end |
Also available in: Unified diff
fixes #17735 - export content-hosts count greater than page size
vcr - full re-record