Ensures that the syslog servers are set to the specified values. A value of None will be ignored.

    name: The name of the module function to execute.

    primary(str): The IP address or FQDN of the primary syslog server.

    secondary(str): The IP address or FQDN of the secondary syslog server.

    SLS Example:

    .. code-block:: yaml

        syslog_configuration:
          cimc.syslog:
            - primary: 10.10.10.10
            - secondary: foo.bar.com

def syslog(name, primary=None, secondary=None):
    '''
    Ensures that the syslog servers are set to the specified values. A value of None will be ignored.

    name: The name of the module function to execute.

    primary(str): The IP address or FQDN of the primary syslog server.

    secondary(str): The IP address or FQDN of the secondary syslog server.

    SLS Example:

    .. code-block:: yaml

        syslog_configuration:
          cimc.syslog:
            - primary: 10.10.10.10
            - secondary: foo.bar.com

    '''
    ret = _default_ret(name)

    conf = __salt__['cimc.get_syslog']()

    req_change = False

    if primary:
        prim_change = True
        if 'outConfigs' in conf and 'commSyslogClient' in conf['outConfigs']:
            for entry in conf['outConfigs']['commSyslogClient']:
                if entry['name'] != 'primary':
                    continue
                if entry['adminState'] == 'enabled' and entry['hostname'] == primary:
                    prim_change = False

        if prim_change:
            try:
                update = __salt__['cimc.set_syslog_server'](primary, "primary")
                if update['outConfig']['commSyslogClient'][0]['status'] == 'modified':
                    req_change = True
                else:
                    ret['result'] = False
                    ret['comment'] = "Error setting primary SYSLOG server."
                    return ret
            except Exception as err:
                ret['result'] = False
                ret['comment'] = "Error setting primary SYSLOG server."
                log.error(err)
                return ret

    if secondary:
        sec_change = True
        if 'outConfig' in conf and 'commSyslogClient' in conf['outConfig']:
            for entry in conf['outConfig']['commSyslogClient']:
                if entry['name'] != 'secondary':
                    continue
                if entry['adminState'] == 'enabled' and entry['hostname'] == secondary:
                    sec_change = False

        if sec_change:
            try:
                update = __salt__['cimc.set_syslog_server'](secondary, "secondary")
                if update['outConfig']['commSyslogClient'][0]['status'] == 'modified':
                    req_change = True
                else:
                    ret['result'] = False
                    ret['comment'] = "Error setting secondary SYSLOG server."
                    return ret
            except Exception as err:
                ret['result'] = False
                ret['comment'] = "Error setting secondary SYSLOG server."
                log.error(err)
                return ret

    if req_change:
        ret['changes']['before'] = conf
        ret['changes']['after'] = __salt__['cimc.get_syslog']()
        ret['comment'] = "SYSLOG settings modified."
    else:
        ret['comment'] = "SYSLOG already configured. No changes required."

    ret['result'] = True

    return ret