# File lib/hammer_cli_csv/domains.rb, line 61
      def create_domains_from_csv(line)
        line[COUNT].to_i.times do |number|
          name = namify(line[NAME], number)
          if !@existing.include? name
            print "Creating domain '#{name}'..." if option_verbose?
            domain_id = @api.resource(:domains).call(:create, {
                                                       'name' => name
                                                     })['id']
          else
            print "Updating domain '#{name}'..." if option_verbose?
            domain_id = @api.resource(:domains).call(:update, {
                                                       'id' => @existing[name],
                                                       'name' => name
                                                     })['id']
          end

          # Update associated resources
          domains ||= {}
          CSV.parse_line(line[ORGANIZATIONS]).each do |organization|
            organization_id = foreman_organization(:name => organization)
            if domains[organization].nil?
              domains[organization] = @api.resource(:organizations).call(:show, {'id' => organization_id})['domains'].collect do |domain|
                domain['id']
              end
            end
            domains[organization] += [domain_id] if !domains[organization].include? domain_id

            @api.resource(:organizations).call(:update, {
                                                 'id' => organization_id,
                                                 'organization' => {
                                                   'domain_ids' => domains[organization]
                                                 }
                                               })
          end

          print "done\n" if option_verbose?
        end
      rescue RuntimeError => e
        raise "#{e}\n       #{line}"
      end