blob: ced671ed2a2a8c3d8b0e7a1c4d069370ce73e9ba [file] [log] [blame]
import logging
logger = logging.getLogger(__name__)
def __virtual__():
'''
Only load if jenkins_common module exist.
'''
if 'jenkins_common.call_groovy_script' not in __salt__:
return (
False,
'The jenkins_audittrail state module cannot be loaded: '
'jenkins_common not found')
return True
def config (name, type="console", log="", limit=0, count=0, output="STD_OUT",
date_format="yyyy-MM-dd HH:mm:ss:SSS", log_prefix="", syslog_server_hostname="",
syslog_server_port=514, syslog_facility="SYSLOG",
app_name="jenkins", message_hostname="", message_format="RFC_3164"):
"""
Jenkins AuditTrail logging config state method
:param type: logger type. one of: console (default), file, syslog
Console Logger params:
:param output: STD_OUT or STD_ERR
:param date_format
:param log_prefix
File Logger params:
:param log: path to log file
:param limit: log file size
:param count: log file count to keep
Syslog Logger params:
:param syslog_server_hostname
:param syslog_server_port
:param syslog_facility
:param app_name
:param message_hostname
:param message_format: RFC_3164 or RFC_5424
:returns: salt-specified state dict
"""
template = __salt__['jenkins_common.load_template'](
'salt://jenkins/files/groovy/audittrail_config.template',
__env__)
return __salt__['jenkins_common.api_call'](name, template,
["CREATED", "EXISTS"],
{
'logger_type': type,
'output': output,
'date_format': date_format,
'log_prefix': log_prefix if log_prefix else "",
'log': log if log else "",
'limit': limit,
'count': count,
'syslog_server_hostname': syslog_server_hostname if syslog_server_hostname else "",
'syslog_server_port': syslog_server_port,
'syslog_facility': syslog_facility,
'app_name': app_name,
'message_hostname': message_hostname if message_hostname else "",
'message_format': message_format if message_format else "",
},
'AuditTrail logger configuration')
def params (name, pattern="", log_build_cause=True):
"""
Jenkins AuditTrail logging params state method
:param pattern
:param log_build_cause
:returns: salt-specified state dict
"""
template = __salt__['jenkins_common.load_template'](
'salt://jenkins/files/groovy/audittrail_params.template',
__env__)
return __salt__['jenkins_common.api_call'](name, template,
["CHANGED", "EXISTS"],
{
'pattern': pattern if pattern else "",
'log_build_cause': str(log_build_cause).lower(),
},
'AuditTrail logger params')