Set parameters for iDRAC in a blade.

    :param idrac_password: Password to use to connect to the iDRACs directly
        (idrac_ipmi and idrac_dnsname must be set directly on the iDRAC.  They
        can't be set through the CMC.  If this password is present, use it
        instead of the CMC password)
    :param idrac_ipmi: Enable/Disable IPMI over LAN
    :param idrac_ip: Set IP address for iDRAC
    :param idrac_netmask: Set netmask for iDRAC
    :param idrac_gateway: Set gateway for iDRAC
    :param idrac_dhcp: Turn on DHCP for iDRAC (True turns on, False does
        nothing becaause setting a static IP will disable DHCP).

    :return: A standard Salt changes dictionary

    NOTE: If any of the IP address settings is configured, all of ip, netmask,
    and gateway must be present

def blade_idrac(name, idrac_password=None, idrac_ipmi=None,
                idrac_ip=None, idrac_netmask=None, idrac_gateway=None,
                idrac_dnsname=None,
                idrac_dhcp=None):
    '''
    Set parameters for iDRAC in a blade.

    :param idrac_password: Password to use to connect to the iDRACs directly
        (idrac_ipmi and idrac_dnsname must be set directly on the iDRAC.  They
        can't be set through the CMC.  If this password is present, use it
        instead of the CMC password)
    :param idrac_ipmi: Enable/Disable IPMI over LAN
    :param idrac_ip: Set IP address for iDRAC
    :param idrac_netmask: Set netmask for iDRAC
    :param idrac_gateway: Set gateway for iDRAC
    :param idrac_dhcp: Turn on DHCP for iDRAC (True turns on, False does
        nothing becaause setting a static IP will disable DHCP).

    :return: A standard Salt changes dictionary

    NOTE: If any of the IP address settings is configured, all of ip, netmask,
    and gateway must be present
    '''

    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    if not idrac_password:
        (username, password) = __salt__['chassis.chassis_credentials']()
    else:
        password = idrac_password

    module_network = __salt__['chassis.cmd']('network_info', module=name)
    current_idrac_ip = module_network['Network']['IP Address']

    if idrac_ipmi is not None:
        if idrac_ipmi is True or idrac_ipmi == 1:
            idrac_ipmi = '1'
        if idrac_ipmi is False or idrac_ipmi == 0:
            idrac_ipmi = '0'
        current_ipmi = __salt__['dracr.get_general']('cfgIpmiLan', 'cfgIpmiLanEnable',
                                                     host=current_idrac_ip, admin_username='root',
                                                     admin_password=password)

        if current_ipmi != idrac_ipmi:
            ch = {'Old': current_ipmi, 'New': idrac_ipmi}
            ret['changes']['IPMI'] = ch

    if idrac_dnsname is not None:
        dnsret = __salt__['dracr.get_dns_dracname'](host=current_idrac_ip,
                                                    admin_username='root',
                                                    admin_password=password)
        current_dnsname = dnsret['[Key=iDRAC.Embedded.1#NIC.1]']['DNSRacName']
        if current_dnsname != idrac_dnsname:
            ch = {'Old': current_dnsname,
                  'New': idrac_dnsname}
            ret['changes']['DNSRacName'] = ch

    if idrac_dhcp is not None or idrac_ip or idrac_netmask or idrac_gateway:
        if idrac_dhcp is True or idrac_dhcp == 1:
            idrac_dhcp = 1
        else:
            idrac_dhcp = 0
        if six.text_type(module_network['Network']['DHCP Enabled']) == '0' and idrac_dhcp == 1:
            ch = {'Old': module_network['Network']['DHCP Enabled'],
                  'New': idrac_dhcp}
            ret['changes']['DRAC DHCP'] = ch

        if idrac_dhcp == 0 and all([idrac_ip, idrac_netmask, idrac_netmask]):
            current_network = __salt__['chassis.cmd']('network_info',
                                                      module=name)
            old_ipv4 = {}
            new_ipv4 = {}
            if current_network['Network']['IP Address'] != idrac_ip:
                old_ipv4['ip'] = current_network['Network']['IP Address']
                new_ipv4['ip'] = idrac_ip
            if current_network['Network']['Subnet Mask'] != idrac_netmask:
                old_ipv4['netmask'] = current_network['Network']['Subnet Mask']
                new_ipv4['netmask'] = idrac_netmask
            if current_network['Network']['Gateway'] != idrac_gateway:
                old_ipv4['gateway'] = current_network['Network']['Gateway']
                new_ipv4['gateway'] = idrac_gateway

            if new_ipv4 != {}:
                ret['changes']['Network'] = {}
                ret['changes']['Network']['Old'] = old_ipv4
                ret['changes']['Network']['New'] = new_ipv4

    if ret['changes'] == {}:
        ret['comment'] = 'iDRAC on blade is already in the desired state.'
        return ret

    if __opts__['test'] and ret['changes'] != {}:
        ret['result'] = None
        ret['comment'] = 'iDRAC on blade will change.'
        return ret

    if 'IPMI' in ret['changes']:
        ipmi_result = __salt__['dracr.set_general']('cfgIpmiLan',
                                                    'cfgIpmiLanEnable',
                                                    idrac_ipmi,
                                                    host=current_idrac_ip,
                                                    admin_username='root',
                                                    admin_password=password)
        if not ipmi_result:
            ret['result'] = False
            ret['changes']['IPMI']['success'] = False

    if 'DNSRacName' in ret['changes']:
        dnsracname_result = __salt__['dracr.set_dns_dracname'](idrac_dnsname,
            host=current_idrac_ip,
            admin_username='root',
            admin_password=password)
        if dnsracname_result['retcode'] == 0:
            ret['changes']['DNSRacName']['success'] = True
        else:
            ret['result'] = False
            ret['changes']['DNSRacName']['success'] = False
            ret['changes']['DNSRacName']['return'] = dnsracname_result

    if 'DRAC DHCP' in ret['changes']:
        dhcp_result = __salt__['chassis.cmd']('set_niccfg', dhcp=idrac_dhcp)
        if dhcp_result['retcode']:
            ret['changes']['DRAC DHCP']['success'] = True
        else:
            ret['result'] = False
            ret['changes']['DRAC DHCP']['success'] = False
            ret['changes']['DRAC DHCP']['return'] = dhcp_result

    if 'Network' in ret['changes']:
        network_result = __salt__['chassis.cmd']('set_niccfg', ip=idrac_ip,
                                                 netmask=idrac_netmask,
                                                 gateway=idrac_gateway,
                                                 module=name)
        if network_result['retcode'] == 0:
            ret['changes']['Network']['success'] = True
        else:
            ret['result'] = False
            ret['changes']['Network']['success'] = False
            ret['changes']['Network']['return'] = network_result

    return ret