@@ -250,6 +250,12 @@ def generate_sonic_config(device, hwsku, device_as_mapping=None, config_version=
250250 # Add Loopback configuration
251251 _add_loopback_configuration (config , loopback_info )
252252
253+ # Add log-server configuration
254+ _add_log_server_configuration (config , device )
255+
256+ # Add SNMP configuration
257+ _add_snmp_configuration (config , device )
258+
253259 # Add management interface configuration
254260 if oob_ip_result :
255261 oob_ip , prefix_len = oob_ip_result
@@ -2084,3 +2090,27 @@ def _add_portchannel_configuration(config, portchannel_info):
20842090 logger .debug (
20852091 f"Added port channel { pc_name } with { len (pc_data ['members' ])} members"
20862092 )
2093+
2094+ def _add_log_server_configuration (config , device ):
2095+ """Add SYSLOG_SERVER configuration to device config.
2096+
2097+ The configuration is taken from multiple _segment_log_server_* variables
2098+ in the config_context of the device.
2099+ """
2100+ hosts = device .config_context .get ("_segment_log_server_hosts" , [])
2101+ if hosts :
2102+ proto = device .config_context .get ("_segment_log_server_proto" , "udp" )
2103+ severity = device .config_context .get ("_segment_log_server_severity" , "info" )
2104+ vrf = device .config_context .get ("_segment_log_server_vrf" , "mgmt" )
2105+ config ["SYSLOG_SERVER" ] = {}
2106+ for host in hosts :
2107+ config ["SYSLOG_SERVER" ][host ] = {}
2108+ config ["SYSLOG_SERVER" ][host ]["message-type" ] = "log"
2109+ config ["SYSLOG_SERVER" ][host ]["protocol" ] = proto .upper ()
2110+ config ["SYSLOG_SERVER" ][host ]["remote-port" ] = "514"
2111+ config ["SYSLOG_SERVER" ][host ]["severity" ] = severity
2112+ config ["SYSLOG_SERVER" ][host ]["vrf_name" ] = vrf
2113+
2114+ logger .debug (
2115+ f"Added syslog_server { host } "
2116+ )
0 commit comments