From f52b4a16e20d46d52aa0dfd85a488ee4e57fa8ce Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Thu, 12 Dec 2024 02:11:22 +0000 Subject: [PATCH 1/3] Update smartswitch golden config --- ansible/golden_config_db/smartswitch_t1-28-lag.json | 12 ++++++++++++ ansible/library/generate_golden_config_db.py | 9 +++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index 1e9a0f6b4b8..a5f959b681b 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -107,5 +107,17 @@ "bridge": "bridge-midplane", "ip_prefix": "169.254.200.254/24" } + }, + "GNMI": { + "certs": { + "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", + "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer", + "server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key" + }, + "gnmi": { + "client_auth": "true", + "log_level": "2", + "port": "50052" + } } } diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 7bf0dd72203..33cce0e16e6 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -101,10 +101,15 @@ def generate_smartswitch_golden_config_db(self): ori_config_db = json.loads(out) if "DEVICE_METADATA" not in ori_config_db or "localhost" not in ori_config_db["DEVICE_METADATA"]: return "{}" - ori_config_db["DEVICE_METADATA"]["localhost"]["subtype"] = "SmartSwitch" + + if "FEATURE" not in ori_config_db or "dhcp_server" not in ori_config_db["FEATURE"]: + return "{}" + ori_config_db["FEATURE"]["dhcp_server"]["state"] = "enabled" + gold_config_db = { - "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]) + "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]), + "FEATURE": copy.deepcopy(ori_config_db["FEATURE"]) } # Generate dhcp_server related configuration From 8c096ea683c5635dfc7aff15de03f8f99994cd01 Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Thu, 12 Dec 2024 08:41:55 +0000 Subject: [PATCH 2/3] trim space --- ansible/golden_config_db/smartswitch_t1-28-lag.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index a5f959b681b..6db093155fa 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -113,11 +113,11 @@ "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer", "server_key": "/etc/sonic/telemetry/streamingtelemetryserver.key" - }, + }, "gnmi": { "client_auth": "true", "log_level": "2", "port": "50052" - } + } } } From 7b09f820df4804dea6f18ee81311faf38570f5c6 Mon Sep 17 00:00:00 2001 From: jingwenxie Date: Fri, 13 Dec 2024 05:05:28 +0000 Subject: [PATCH 3/3] update format --- .../smartswitch_t1-28-lag.json | 14 +++++++++---- ansible/library/generate_golden_config_db.py | 20 +++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index 6db093155fa..7117fb396cc 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -1,8 +1,5 @@ { "CHASSIS_MODULE": { - "DPU0": { - "admin_status": "down" - }, "DPU1": { "admin_status": "down" }, @@ -28,7 +25,7 @@ "DHCP_SERVER_IPV4": { "bridge-midplane": { "gateway": "169.254.200.254", - "lease_time": "600", + "lease_time": "31536000", "mode": "PORT", "netmask": "255.255.255.0", "state": "enabled" @@ -119,5 +116,14 @@ "log_level": "2", "port": "50052" } + }, + "STATIC_ROUTE": { + "default|10.2.0.1/32": { + "blackhole": "false", + "distance": "0", + "ifname": "", + "nexthop": "18.0.202.1", + "nexthop-vrf": "default" + } } } diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 33cce0e16e6..0fc7a65c708 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -103,13 +103,29 @@ def generate_smartswitch_golden_config_db(self): return "{}" ori_config_db["DEVICE_METADATA"]["localhost"]["subtype"] = "SmartSwitch" - if "FEATURE" not in ori_config_db or "dhcp_server" not in ori_config_db["FEATURE"]: + if "FEATURE" not in ori_config_db \ + or "dhcp_server" not in ori_config_db["FEATURE"] \ + or "dhcp_relay" not in ori_config_db["FEATURE"]: return "{}" ori_config_db["FEATURE"]["dhcp_server"]["state"] = "enabled" + ori_config_db["FEATURE"]["dhcp_relay"]["state"] = "enabled" + + # Generate INTERFACE table for EthernetBPXX + if "PORT" not in ori_config_db or "INTERFACE" not in ori_config_db: + return "{}" + for i in range(8): + port_key = f"Ethernet-BP{i}" + interface_key = f"Ethernet-BP{i}|18.{i}.202.0/31" + if port_key in ori_config_db["PORT"]: + ori_config_db["PORT"][port_key]["admin_status"] = "up" + ori_config_db["INTERFACE"][port_key] = {} + ori_config_db["INTERFACE"][interface_key] = {} gold_config_db = { "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]), - "FEATURE": copy.deepcopy(ori_config_db["FEATURE"]) + "FEATURE": copy.deepcopy(ori_config_db["FEATURE"]), + "INTERFACE": copy.deepcopy(ori_config_db["INTERFACE"]), + "PORT": copy.deepcopy(ori_config_db["PORT"]) } # Generate dhcp_server related configuration