def handle_row(row, enable)
if row['org_id']
info " Skipping #{row['channel_label']} in organization #{row['org_id']}"
return
end
@channel_to_repo ||= read_channel_mapping_data(option_repository_map)
channel_label = row['channel_label']
channel_id = row['channel_id'].to_i
repo_set_info = @channel_to_repo[channel_label]
if repo_set_info.nil?
info " Skipping nontransferable #{row['channel_label']}"
return
end
get_cache(:products).each do |product_id, product|
product['product_content'].each do |rs|
rs_id = rs['content']['id']
rs_url = rs['content']['contentUrl']
next if repo_set_info['set-url'] != rs_url
product_org = lookup_entity_in_cache(:organizations, {'label' => product['organization']['label']})
composite_rhcv_id = [get_original_id(:organizations, product_org['id']), channel_id]
if enable
rh_repo = enable_repos(product_org, product_id, rs_id, repo_set_info, row)
next if rh_repo.nil? || option_dry_run?
next unless option_synchronize?
with_synced_repo rh_repo do
cv = create_entity(
:redhat_content_views,
{
:organization_id => product_org['id'],
:name => row['channel_name'],
:description => 'Red Hat channel migrated from Satellite 5',
:repository_ids => [rh_repo['id']]
},
composite_rhcv_id)
begin
publish_content_view(cv['id'], :redhat_content_views)
rescue RestClient::Exception => e
msg = JSON.parse(e.response)['displayMessage']
error "#{e.http_code} trying to publish content-view #{row['channel_name']} :\n #{msg}\n"
next
end
end
else
if @pm[:redhat_content_views][composite_rhcv_id]
delete_content_view(get_translated_id(:redhat_content_views, composite_rhcv_id), :redhat_content_views)
end
disable_repos(product_org, product_id, rs_id, repo_set_info, channel_label)
end
end
end
end