Sets DNS host records settings for the requested domain.

    returns True if the host records were set successfully

    sld
        SLD of the domain name

    tld
        TLD of the domain name

    hosts
        Must be passed as a list of Python dictionaries, with each dictionary
        containing the following keys:

        - **hostname**
        - **recordtype** - One of ``A``, ``AAAA``, ``CNAME``, ``MX``, ``MXE``,
          ``TXT``, ``URL``, ``URL301``, or ``FRAME``
        - **address** - URL or IP address
        - **ttl** - An integer between 60 and 60000 (default: ``1800``)

        Additonally, the ``mxpref`` key can be present, but must be accompanied
        by an ``emailtype`` key.

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_domains_dns.set_hosts sld tld hosts

def set_hosts(sld, tld, hosts):
    '''
    Sets DNS host records settings for the requested domain.

    returns True if the host records were set successfully

    sld
        SLD of the domain name

    tld
        TLD of the domain name

    hosts
        Must be passed as a list of Python dictionaries, with each dictionary
        containing the following keys:

        - **hostname**
        - **recordtype** - One of ``A``, ``AAAA``, ``CNAME``, ``MX``, ``MXE``,
          ``TXT``, ``URL``, ``URL301``, or ``FRAME``
        - **address** - URL or IP address
        - **ttl** - An integer between 60 and 60000 (default: ``1800``)

        Additonally, the ``mxpref`` key can be present, but must be accompanied
        by an ``emailtype`` key.

    CLI Example:

    .. code-block:: bash

        salt 'my-minion' namecheap_domains_dns.set_hosts sld tld hosts
    '''
    opts = salt.utils.namecheap.get_opts('namecheap.domains.dns.setHosts')
    opts['SLD'] = sld
    opts['TLD'] = tld
    i = 1
    for hostrecord in hosts:
        str_i = six.text_type(i)
        opts['HostName' + str_i] = hostrecord['hostname']
        opts['RecordType' + str_i] = hostrecord['recordtype']
        opts['Address' + str_i] = hostrecord['address']
        if 'ttl' in hostrecord:
            opts['TTL' + str_i] = hostrecord['ttl']
        if 'mxpref' in hostrecord:
            opts['MXPref' + str_i] = hostrecord['mxpref']
            opts['EmailType'] = hostrecord['emailtype']
        i += 1

    response_xml = salt.utils.namecheap.post_request(opts)
    if response_xml is None:
        return False

    dnsresult = response_xml.getElementsByTagName('DomainDNSSetHostsResult')[0]
    return salt.utils.namecheap.string_to_value(dnsresult.getAttribute('IsSuccess'))