-
Notifications
You must be signed in to change notification settings - Fork 3
sonic/config_generator: align syslog and mgmt_port values with schema #2260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2074,6 +2074,16 @@ def _add_portchannel_configuration(config, portchannel_info): | |
| ) | ||
|
|
||
|
|
||
| # Map common syslog severity aliases to the SONiC-accepted set. | ||
| # SONiC schema accepts: none, debug, info, notice, warn, error, crit. | ||
| _SYSLOG_SEVERITY_ALIASES = { | ||
| "informational": "info", | ||
| "warning": "warn", | ||
| "err": "error", | ||
| "critical": "crit", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you omit the other three? at least debug sounds like it could be useful in certain cases |
||
| } | ||
|
|
||
|
|
||
| def _add_log_server_configuration(config, device): | ||
| """Add SYSLOG_SERVER configuration to device config. | ||
|
|
||
|
|
@@ -2085,11 +2095,14 @@ def _add_log_server_configuration(config, device): | |
| proto = device.config_context.get("_segment_log_server_proto", "udp") | ||
| severity = device.config_context.get("_segment_log_server_severity", "info") | ||
| vrf = device.config_context.get("_segment_log_server_vrf", "mgmt") | ||
| proto = proto.strip().lower() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is uppercase in the generated config, I would prefer to stick to that |
||
| severity = severity.strip().lower() | ||
| severity = _SYSLOG_SEVERITY_ALIASES.get(severity, severity) | ||
|
sourcery-ai[bot] marked this conversation as resolved.
|
||
| config["SYSLOG_SERVER"] = {} | ||
| for host in hosts: | ||
| config["SYSLOG_SERVER"][host] = {} | ||
| config["SYSLOG_SERVER"][host]["message-type"] = "log" | ||
| config["SYSLOG_SERVER"][host]["protocol"] = proto.upper() | ||
| config["SYSLOG_SERVER"][host]["protocol"] = proto | ||
| config["SYSLOG_SERVER"][host]["remote-port"] = "514" | ||
| config["SYSLOG_SERVER"][host]["severity"] = severity | ||
| config["SYSLOG_SERVER"][host]["vrf_name"] = vrf | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, I'd prefer to stick to how the config is generated and amend the scheme if needed