# File lib/hammer_cli_import/repositoryenable.rb, line 140
      def enable_repos(org, prod_id, repo_set_id, info, row)
        channel_label = row['channel_label']
        channel_id = row ['channel_id'].to_i
        repo = lookup_entity_in_cache(
          :redhat_repositories,
          {
            'content_id' => repo_set_id,
            'organization' => {'label' => org['label']}
          })
        if repo
          info "Repository #{[repo['url'], repo['label']].compact[0]} already enabled as #{repo['id']}"
          return repo
        end
        info "Enabling #{info['url']} for channel #{channel_label} in org #{org['id']}"
        begin
          unless option_dry_run?
            rc = api_call(
              :repository_sets,
              :enable,
              'product_id' => prod_id,
              'id' => repo_set_id,
              'basearch' => info['arch'],
              'releasever' => info['version'])

            original_org_id = get_original_id(:organizations, org['id'])
            map_entity(:redhat_repositories, [original_org_id, channel_id], rc['input']['repository']['id'])
            # store to cache (using lookup_entity, because :redhat_repositories api
            # does not return full repository hash)
            return lookup_entity(:redhat_repositories, rc['input']['repository']['id'], true)
          end
        rescue RestClient::Exception  => e
          if e.http_code == 409
            info '...already enabled.'
          else
            error "...unknown error #{e.http_code}, #{e.message} - skipping."
          end
        end
      end