@@ -290,6 +290,44 @@ def safe_open_template(template_path):
290290
291291 return rendered_json
292292
293+ def update_dns_config (self , config ):
294+ # Generate dns_server related configuration
295+ rc , out , err = self .module .run_command ("cat {}" .format (DNS_CONFIG_PATH ))
296+ if rc != 0 :
297+ self .module .fail_json (msg = "Failed to get dns config: {}" .format (err ))
298+ try :
299+ dns_config_obj = json .loads (out )
300+ except json .JSONDecodeError :
301+ self .module .fail_json (msg = "Invalid JSON in DNS config: {}" .format (out ))
302+ if "DNS_NAMESERVER" in dns_config_obj :
303+ ori_config_db = json .loads (config )
304+ if multi_asic .is_multi_asic ():
305+ for key , value in ori_config_db .items ():
306+ value .update (dns_config_obj )
307+ else :
308+ ori_config_db .update (dns_config_obj )
309+ return json .dumps (ori_config_db , indent = 4 )
310+ else :
311+ return config
312+
313+ def generate_lt2_ft2_golden_config_db (self ):
314+ """
315+ Generate golden_config for FT2 to enable FEC.
316+ **Only PORT table is updated**.
317+ """
318+ SUPPORTED_TOPO = ["ft2-64" , "lt2-p32o64" , "lt2-o128" ]
319+ if self .topo_name not in SUPPORTED_TOPO :
320+ return "{}"
321+ SUPPORTED_PORT_SPEED = ["200000" , "400000" , "800000" ]
322+ ori_config = json .loads (self .get_config_from_minigraph ())
323+ port_config = ori_config .get ("PORT" , {})
324+ for name , config in port_config .items ():
325+ # Enable FEC for ports with supported speed
326+ if config ["speed" ] in SUPPORTED_PORT_SPEED and "fec" not in config :
327+ config ["fec" ] = "rs"
328+
329+ return json .dumps ({"PORT" : port_config }, indent = 4 )
330+
293331 def generate (self ):
294332 module_msg = "Success to generate golden_config_db.json"
295333 # topo check
0 commit comments