From ae636ec88001088c601216b94540d60126026c87 Mon Sep 17 00:00:00 2001 From: Yaqiang Zhu Date: Thu, 12 Dec 2024 03:14:50 +0800 Subject: [PATCH] [deploy-mg] Disable default_pfcwd_status for m0/mx (#15922) (#16012) What is the motivation for this PR? default_pfcwd_status should be disable for m0 and mx How did you do it? In golden config_db, disable pfcwd for m0 and mx How did you verify/test it? Deploy topo --- ansible/library/generate_golden_config_db.py | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 43411478966..c38853c61ae 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -34,6 +34,25 @@ def __init__(self): self.topo_name = self.module.params['topo_name'] self.port_index_map = self.module.params['port_index_map'] + def generate_mgfx_golden_config_db(self): + rc, out, err = self.module.run_command("sonic-cfggen -H -m -j /etc/sonic/init_cfg.json --print-data") + if rc != 0: + self.module.fail_json(msg="Failed to get config from minigraph: {}".format(err)) + + # Generate config table from init_cfg.ini + ori_config_db = json.loads(out) + + golden_config_db = {} + if "DEVICE_METADATA" in ori_config_db: + golden_config_db["DEVICE_METADATA"] = ori_config_db["DEVICE_METADATA"] + if ("localhost" in golden_config_db["DEVICE_METADATA"] and + "default_pfcwd_status" in golden_config_db["DEVICE_METADATA"]["localhost"]): + golden_config_db["DEVICE_METADATA"]["localhost"]["default_pfcwd_status"] = "disable" + + if self.topo_name == "mx": + golden_config_db.update(self.generate_mx_golden_config_db()) + return json.dumps(golden_config_db, indent=4) + def generate_mx_golden_config_db(self): """ If FEATURE table in init_cfg.json contains dhcp_server, enable it. @@ -70,11 +89,11 @@ def generate_mx_golden_config_db(self): dhcp_server_config_obj["DHCP_SERVER_IPV4_PORT"] = dhcp_server_port_config gold_config_db.update(dhcp_server_config_obj) - return json.dumps(gold_config_db, indent=4) + return gold_config_db def generate(self): - if self.topo_name == "mx": - config = self.generate_mx_golden_config_db() + if self.topo_name == "mx" or "m0" in self.topo_name: + config = self.generate_mgfx_golden_config_db() else: config = "{}"