summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--priv/schema/rabbit.schema48
-rw-r--r--test/config_schema_SUITE_data/rabbit.snippets2
2 files changed, 49 insertions, 1 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
diff --git a/test/config_schema_SUITE_data/rabbit.snippets b/test/config_schema_SUITE_data/rabbit.snippets
index f65afb77eb..685b05b3dc 100644
--- a/test/config_schema_SUITE_data/rabbit.snippets
+++ b/test/config_schema_SUITE_data/rabbit.snippets
@@ -540,7 +540,7 @@ credential_validator.regexp = ^abc\\d+",
log.syslog.identity = rabbitmq
log.syslog.facility = user
log.syslog.multiline_mode = true
- log.syslog.host = 10.10.10.10
+ log.syslog.ip = 10.10.10.10
log.syslog.port = 123",
[
{rabbit,[{log, [{syslog, [{enabled, true}]}]}]},