diff options
Diffstat (limited to 'priv/schema')
| -rw-r--r-- | priv/schema/rabbit.schema | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/priv/schema/rabbit.schema b/priv/schema/rabbit.schema index 82b9905848..c5e38dddf8 100644 --- a/priv/schema/rabbit.schema +++ b/priv/schema/rabbit.schema @@ -1067,6 +1067,27 @@ end}. {mapping, "log.syslog", "rabbit.log.syslog.enabled", [ {datatype, {enum, [true, false]}} ]}. + +{translation, "rabbit.log.syslog.enabled", +fun(Conf) -> + case cuttlefish:conf_get("log.syslog", Conf) of + true -> + case cuttlefish:conf_get("log.syslog.ip", Conf, undefined) of + undefined -> + case cuttlefish:conf_get("log.syslog.host", Conf, undefined) of + undefined -> + cuttlefish:invalid("Either log.syslog.ip or log.syslog.host must be set"); + _Host -> + true + end; + _IpAddr -> + true + end; + _ -> + [] + end +end}. + {mapping, "log.syslog.level", "rabbit.log.syslog.level", [ {datatype, {enum, [debug, info, notice, warning, error, critical, alert, emergency, none]}} ]}. @@ -1086,10 +1107,31 @@ end}. {datatype, {enum, [true, false]}} ]}. +{mapping, "log.syslog.ip", "syslog.dest_host", [ + {datatype, string}, + {validators, ["is_ip"]} +]}. + {mapping, "log.syslog.host", "syslog.dest_host", [ {datatype, string} ]}. +{translation, "syslog.dest_host", +fun(Conf) -> + case cuttlefish:conf_get("log.syslog", Conf) of + true -> + case cuttlefish:conf_get("log.syslog.ip", Conf, undefined) of + undefined -> + % If log.syslog.ip is not set, then this must be set + cuttlefish:conf_get("log.syslog.host", Conf); + IpAddr -> + IpAddr + end; + _ -> + cuttlefish:invalid("log.syslog must be set to true to set log.syslog.host or log.syslog.ip") + end +end}. + {mapping, "log.syslog.port", "syslog.dest_port", [ {datatype, integer} ]}. @@ -1352,6 +1394,12 @@ fun(File) -> element(1, ReadFile) == ok end}. +{validator, "is_ip", "string is a valid IP address", +fun(IpStr) -> + Res = inet:parse_address(IpStr), + element(1, Res) == ok +end}. + {validator, "non_negative_integer", "number should be greater or equal to zero", fun(Int) when is_integer(Int) -> Int >= 0 |
