From 0c09131b816a197cb7f176bb4e43f3d7583eb68d Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Mon, 23 Dec 2024 14:55:24 -0800 Subject: [PATCH 01/10] Summary:New smartswitch DPU config template --- ansible/config_sonic_basedon_testbed.yml | 10 +++ ansible/lab | 40 ++++++++++++ ansible/templates/dpu_config.j2 | 80 ++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 ansible/templates/dpu_config.j2 diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index 44ab5a3e1a0..a6323ccb1a4 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -702,6 +702,16 @@ shell: bash "/etc/sonic/apply_clet.sh" when: stat_result.stat.exists is defined and stat_result.stat.exists + - block: + - name: create dpu config file for SONiC device + template: src=templates/dpu_config.j2 + dest=/etc/sonic/dpu_config.json + become: true + + - name: active dpu config + become: true + shell: sonic-cfggen -j /etc/sonic/dpu_config.json -w + - block: - name: create isis config file for SONiC device template: src=templates/isis_config.j2 diff --git a/ansible/lab b/ansible/lab index 7308519349a..716b79de67e 100644 --- a/ansible/lab +++ b/ansible/lab @@ -234,3 +234,43 @@ sonic_cisco_vs: hwsku: cisco-8101-p4-32x100-vs ansible_host: 10.250.0.125 ansible_hostv6: fec0::ffff:afa:13 + +sonic_cisco_smartswitch: + vars: + hwsku: Cisco-8102-28FH-DPU-O-T1 + dpu_username: admin + iface_speed: 400000 + num_asics: 1 + plt_reboot_dict: + acl/test_acl.py::TestAclWithReboot: + timeout: 540 + wait: 660 + + midplane_network: + bridge_name: "bridge-midplane" + bridge_address: "169.254.200.254/24" + + device_metadata: + localhost: + subtype: "SmartSwitch" + + feature: + dhcp_server: + auto_restart: "enabled" + state: "enabled" + dhcp_relay: + auto_restart: "enabled" + state: "enabled" + + mid_plane_bridge: + global: + bridge: "bridge-midplane" + ip_prefix: "169.254.200.254/24" + + dhcp_server_ipv4: + bridge-midplane: + gateway: "169.254.200.254" + lease_time: "600000000" + mode: "PORT" + netmask: "255.255.255.0" + state: "enabled" diff --git a/ansible/templates/dpu_config.j2 b/ansible/templates/dpu_config.j2 new file mode 100644 index 00000000000..a5e138007b7 --- /dev/null +++ b/ansible/templates/dpu_config.j2 @@ -0,0 +1,80 @@ +{ + "CHASSIS_MODULE": { + {% for dpu in range(8) -%} + "DPU{{ dpu }}": { + "admin_status": "up" + }{% if not loop.last %},{% endif %} + {%- endfor %} + + }, + "midplane_network": { + "bridge_name": "{{ midplane_network.bridge_name }}", + "bridge_address": "{{ midplane_network.bridge_address }}" + }, + "DEVICE_METADATA": { + "localhost": { + "subtype": "{{ device_metadata.localhost.subtype }}" + } + }, + "FEATURE": { + "dhcp_server": { + "auto_restart": "{{ feature.dhcp_server.auto_restart }}", + "state": "{{ feature.dhcp_server.state }}" + }, + "dhcp_relay": { + "auto_restart": "{{ feature.dhcp_relay.auto_restart }}", + "state": "{{ feature.dhcp_relay.state }}" + } + }, + "MID_PLANE_BRIDGE": { + "GLOBAL": { + "bridge": "{{ mid_plane_bridge.global.bridge }}", + "ip_prefix": "{{ mid_plane_bridge.global.ip_prefix }}" + } + }, + "DHCP_SERVER_IPV4": { + "{{ midplane_network.bridge_name }}": { + "gateway": "{{ dhcp_server_ipv4[midplane_network.bridge_name].gateway }}", + "lease_time": "{{ dhcp_server_ipv4[midplane_network.bridge_name].lease_time }}", + "mode": "{{ dhcp_server_ipv4[midplane_network.bridge_name].mode }}", + "netmask": "{{ dhcp_server_ipv4[midplane_network.bridge_name].netmask }}", + "state": "{{ dhcp_server_ipv4[midplane_network.bridge_name].state }}" + + } + }, + "DHCP_SERVER_IPV4_PORT": { + {% for dpu in range(8) -%} + "{{ midplane_network.bridge_name }}|dpu{{ dpu }}": { + "ips": [ + "{{ '169.254.200.' ~ dpu }}" + ] + }{% if not loop.last %},{% endif %} + {%- endfor %} + + }, + "DPUS": { + {% for dpu in range(8) -%} + "dpu{{ dpu }}": { + "midplane_interface": "dpu{{ dpu }}" + }{% if not loop.last %},{% endif %} + {%- endfor %} + + }, + "INTERFACE": { + {% for i in range(8) -%} + "Ethernet-BP{{ i }}": {}, + "Ethernet-BP{{ i }}|18.{{ i }}.202.0/31": {}{% if not loop.last %}, + {% endif %} + {%- endfor %} + + }, + "PORT": { + {% for dpu in range(8) -%} + "Ethernet-BP{{ dpu }}": { + "admin_status": "up" + }{% if not loop.last %},{% endif %} + {%- endfor %} + + } + +} From 6dc9e0d98e4d1c267fb18b234cbd892a5ba0accb Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Mon, 6 Jan 2025 23:12:28 -0800 Subject: [PATCH 02/10] Summary: smartswitch DPU config --- ansible/config_sonic_basedon_testbed.yml | 10 --- ansible/lab | 40 --------- ansible/library/generate_golden_config_db.py | 95 +++++++++++++++++++- ansible/templates/dpu_config.j2 | 80 ----------------- 4 files changed, 91 insertions(+), 134 deletions(-) delete mode 100644 ansible/templates/dpu_config.j2 diff --git a/ansible/config_sonic_basedon_testbed.yml b/ansible/config_sonic_basedon_testbed.yml index a6323ccb1a4..44ab5a3e1a0 100644 --- a/ansible/config_sonic_basedon_testbed.yml +++ b/ansible/config_sonic_basedon_testbed.yml @@ -702,16 +702,6 @@ shell: bash "/etc/sonic/apply_clet.sh" when: stat_result.stat.exists is defined and stat_result.stat.exists - - block: - - name: create dpu config file for SONiC device - template: src=templates/dpu_config.j2 - dest=/etc/sonic/dpu_config.json - become: true - - - name: active dpu config - become: true - shell: sonic-cfggen -j /etc/sonic/dpu_config.json -w - - block: - name: create isis config file for SONiC device template: src=templates/isis_config.j2 diff --git a/ansible/lab b/ansible/lab index 716b79de67e..7308519349a 100644 --- a/ansible/lab +++ b/ansible/lab @@ -234,43 +234,3 @@ sonic_cisco_vs: hwsku: cisco-8101-p4-32x100-vs ansible_host: 10.250.0.125 ansible_hostv6: fec0::ffff:afa:13 - -sonic_cisco_smartswitch: - vars: - hwsku: Cisco-8102-28FH-DPU-O-T1 - dpu_username: admin - iface_speed: 400000 - num_asics: 1 - plt_reboot_dict: - acl/test_acl.py::TestAclWithReboot: - timeout: 540 - wait: 660 - - midplane_network: - bridge_name: "bridge-midplane" - bridge_address: "169.254.200.254/24" - - device_metadata: - localhost: - subtype: "SmartSwitch" - - feature: - dhcp_server: - auto_restart: "enabled" - state: "enabled" - dhcp_relay: - auto_restart: "enabled" - state: "enabled" - - mid_plane_bridge: - global: - bridge: "bridge-midplane" - ip_prefix: "169.254.200.254/24" - - dhcp_server_ipv4: - bridge-midplane: - gateway: "169.254.200.254" - lease_time: "600000000" - mode: "PORT" - netmask: "255.255.255.0" - state: "enabled" diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index a40efa499ac..2809e8173fc 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -26,6 +26,15 @@ TEMP_SMARTSWITCH_CONFIG_PATH = "/tmp/smartswitch.json" DUMMY_QUOTA = "dummy_single_quota" +smartswitch_hwsku_config = { + "Cisco-8102-28FH-DPU-O-T1": { + "dpu_num": 8, + "port_key": "Ethernet-BP{}", + "interface_key": "Ethernet-BP{}|18.{}.202.0/31", + "dpu_key": "dpu{}" + } +} + class GenerateGoldenConfigDBModule(object): def __init__(self): @@ -66,7 +75,7 @@ def generate_mx_golden_config_db(self): # Generate FEATURE table from init_cfg.ini ori_config_db = json.loads(out) if "FEATURE" not in ori_config_db or "dhcp_server" not in ori_config_db["FEATURE"]: - return {} + return "{}" ori_config_db["FEATURE"]["dhcp_server"]["state"] = "enabled" gold_config_db = { @@ -101,13 +110,91 @@ 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" + hwsku = ori_config_db["DEVICE_METADATA"]["localhost"].get("hwsku", None) + + 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 "{}" + + if hwsku not in smartswitch_hwsku_config: + return "{}" + + if "DPUS" not in ori_config_db: + ori_config_db["DPUS"]= {} + + if "DHCP_SERVER_IPV4_PORT" not in ori_config_db: + ori_config_db["DHCP_SERVER_IPV4_PORT"] = {} + if "CHASSIS_MODULE" not in ori_config_db: + ori_config_db["CHASSIS_MODULE"] = {} + + for i in range(smartswitch_hwsku_config[hwsku]["dpu_num"]): + port_key = smartswitch_hwsku_config[hwsku]["port_key"].format(i) + interface_key = smartswitch_hwsku_config[hwsku]["interface_key"].format(i, i) + dpu_key = smartswitch_hwsku_config[hwsku]["dpu_key"].format(i) + + 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] = {} + if dpu_key not in ori_config_db["DPUS"]: + ori_config_db["DPUS"][dpu_key] = {} + ori_config_db["DPUS"][dpu_key]["midplane_interface"] = dpu_key + + key = "bridge-midplane|dpu{}".format(i) + if key not in ori_config_db["DHCP_SERVER_IPV4_PORT"]: + ori_config_db["DHCP_SERVER_IPV4_PORT"][key] = {} + ori_config_db["DHCP_SERVER_IPV4_PORT"][key]["ips"] = ["169.254.200.{}".format(i)] + ori_config_db["CHASSIS_MODULE"]["DPU{}".format(i)] = {"admin_status": "up"} + + midplane_network_config = { + "midplane_network": { + "bridge_name": "bridge-midplane", + "bridge_address": "169.254.200.254/24" + } + } + ori_config_db["MIDPLANE_NETWORK"] = midplane_network_config + mid_plane_bridge_config = { + "GLOBAL": { + "bridge": "bridge-midplane", + "ip_prefix": "169.254.200.254/24" + } + } + + ori_config_db["MID_PLANE_BRIDGE"] = mid_plane_bridge_config + + dhcp_server_ipv4_config = { + "DHCP_SERVER_IPV4": { + "bridge-midplane": { + "gateway": "169.254.200.254", + "lease_time": "600000000", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + } + } + ori_config_db["DHCP_SERVER_IPV4"] = dhcp_server_ipv4_config["DHCP_SERVER_IPV4"] 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"]), + "INTERFACE": copy.deepcopy(ori_config_db["INTERFACE"]), + "PORT": copy.deepcopy(ori_config_db["PORT"]), + "DPUS": copy.deepcopy(ori_config_db["DPUS"]), + "DHCP_SERVER_IPV4_PORT": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4_PORT"]), + "MID_PLANE_BRIDGE": copy.deepcopy(ori_config_db["MID_PLANE_BRIDGE"]), + "DHCP_SERVER_IPV4": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4"]), + "CHASSIS_MODULE": copy.deepcopy(ori_config_db["CHASSIS_MODULE"]) } - # Generate dhcp_server related configuration + #Generate dhcp_server related configuration rc, out, err = self.module.run_command("cat {}".format(TEMP_SMARTSWITCH_CONFIG_PATH)) if rc != 0: self.module.fail_json(msg="Failed to get smartswitch config: {}".format(err)) diff --git a/ansible/templates/dpu_config.j2 b/ansible/templates/dpu_config.j2 deleted file mode 100644 index a5e138007b7..00000000000 --- a/ansible/templates/dpu_config.j2 +++ /dev/null @@ -1,80 +0,0 @@ -{ - "CHASSIS_MODULE": { - {% for dpu in range(8) -%} - "DPU{{ dpu }}": { - "admin_status": "up" - }{% if not loop.last %},{% endif %} - {%- endfor %} - - }, - "midplane_network": { - "bridge_name": "{{ midplane_network.bridge_name }}", - "bridge_address": "{{ midplane_network.bridge_address }}" - }, - "DEVICE_METADATA": { - "localhost": { - "subtype": "{{ device_metadata.localhost.subtype }}" - } - }, - "FEATURE": { - "dhcp_server": { - "auto_restart": "{{ feature.dhcp_server.auto_restart }}", - "state": "{{ feature.dhcp_server.state }}" - }, - "dhcp_relay": { - "auto_restart": "{{ feature.dhcp_relay.auto_restart }}", - "state": "{{ feature.dhcp_relay.state }}" - } - }, - "MID_PLANE_BRIDGE": { - "GLOBAL": { - "bridge": "{{ mid_plane_bridge.global.bridge }}", - "ip_prefix": "{{ mid_plane_bridge.global.ip_prefix }}" - } - }, - "DHCP_SERVER_IPV4": { - "{{ midplane_network.bridge_name }}": { - "gateway": "{{ dhcp_server_ipv4[midplane_network.bridge_name].gateway }}", - "lease_time": "{{ dhcp_server_ipv4[midplane_network.bridge_name].lease_time }}", - "mode": "{{ dhcp_server_ipv4[midplane_network.bridge_name].mode }}", - "netmask": "{{ dhcp_server_ipv4[midplane_network.bridge_name].netmask }}", - "state": "{{ dhcp_server_ipv4[midplane_network.bridge_name].state }}" - - } - }, - "DHCP_SERVER_IPV4_PORT": { - {% for dpu in range(8) -%} - "{{ midplane_network.bridge_name }}|dpu{{ dpu }}": { - "ips": [ - "{{ '169.254.200.' ~ dpu }}" - ] - }{% if not loop.last %},{% endif %} - {%- endfor %} - - }, - "DPUS": { - {% for dpu in range(8) -%} - "dpu{{ dpu }}": { - "midplane_interface": "dpu{{ dpu }}" - }{% if not loop.last %},{% endif %} - {%- endfor %} - - }, - "INTERFACE": { - {% for i in range(8) -%} - "Ethernet-BP{{ i }}": {}, - "Ethernet-BP{{ i }}|18.{{ i }}.202.0/31": {}{% if not loop.last %}, - {% endif %} - {%- endfor %} - - }, - "PORT": { - {% for dpu in range(8) -%} - "Ethernet-BP{{ dpu }}": { - "admin_status": "up" - }{% if not loop.last %},{% endif %} - {%- endfor %} - - } - -} From b49cac62eeecde6574886bf2e36cbf60553f9efb Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Tue, 7 Jan 2025 22:29:33 -0800 Subject: [PATCH 03/10] Removed DPU config which already defined in file "smartswitch_t1-28-lag.json" --- ansible/library/generate_golden_config_db.py | 50 +------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 63c0f12970d..56affee0b46 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -30,8 +30,7 @@ "Cisco-8102-28FH-DPU-O-T1": { "dpu_num": 8, "port_key": "Ethernet-BP{}", - "interface_key": "Ethernet-BP{}|18.{}.202.0/31", - "dpu_key": "dpu{}" + "interface_key": "Ethernet-BP{}|18.{}.202.0/31" } } @@ -127,35 +126,15 @@ def generate_smartswitch_golden_config_db(self): if hwsku not in smartswitch_hwsku_config: return "{}" - if "DPUS" not in ori_config_db: - ori_config_db["DPUS"]= {} - - if "DHCP_SERVER_IPV4_PORT" not in ori_config_db: - ori_config_db["DHCP_SERVER_IPV4_PORT"] = {} - if "CHASSIS_MODULE" not in ori_config_db: - ori_config_db["CHASSIS_MODULE"] = {} - for i in range(smartswitch_hwsku_config[hwsku]["dpu_num"]): port_key = smartswitch_hwsku_config[hwsku]["port_key"].format(i) interface_key = smartswitch_hwsku_config[hwsku]["interface_key"].format(i, i) - dpu_key = smartswitch_hwsku_config[hwsku]["dpu_key"].format(i) - for i in range(smartswitch_hwsku_config["dpu_num"]): - port_key = smartswitch_hwsku_config["port_key"].format(i) - interface_key = smartswitch_hwsku_config["interface_key"].format(i, i) 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] = {} - if dpu_key not in ori_config_db["DPUS"]: - ori_config_db["DPUS"][dpu_key] = {} - ori_config_db["DPUS"][dpu_key]["midplane_interface"] = dpu_key - key = "bridge-midplane|dpu{}".format(i) - if key not in ori_config_db["DHCP_SERVER_IPV4_PORT"]: - ori_config_db["DHCP_SERVER_IPV4_PORT"][key] = {} - ori_config_db["DHCP_SERVER_IPV4_PORT"][key]["ips"] = ["169.254.200.{}".format(i)] - ori_config_db["CHASSIS_MODULE"]["DPU{}".format(i)] = {"admin_status": "up"} midplane_network_config = { "midplane_network": { @@ -164,38 +143,13 @@ def generate_smartswitch_golden_config_db(self): } } ori_config_db["MIDPLANE_NETWORK"] = midplane_network_config - mid_plane_bridge_config = { - "GLOBAL": { - "bridge": "bridge-midplane", - "ip_prefix": "169.254.200.254/24" - } - } - - ori_config_db["MID_PLANE_BRIDGE"] = mid_plane_bridge_config - - dhcp_server_ipv4_config = { - "DHCP_SERVER_IPV4": { - "bridge-midplane": { - "gateway": "169.254.200.254", - "lease_time": "600000000", - "mode": "PORT", - "netmask": "255.255.255.0", - "state": "enabled" - } - } - } - ori_config_db["DHCP_SERVER_IPV4"] = dhcp_server_ipv4_config["DHCP_SERVER_IPV4"] gold_config_db = { "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]), "FEATURE": copy.deepcopy(ori_config_db["FEATURE"]), "INTERFACE": copy.deepcopy(ori_config_db["INTERFACE"]), "PORT": copy.deepcopy(ori_config_db["PORT"]), - "DPUS": copy.deepcopy(ori_config_db["DPUS"]), - "DHCP_SERVER_IPV4_PORT": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4_PORT"]), - "MID_PLANE_BRIDGE": copy.deepcopy(ori_config_db["MID_PLANE_BRIDGE"]), - "DHCP_SERVER_IPV4": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4"]), - "CHASSIS_MODULE": copy.deepcopy(ori_config_db["CHASSIS_MODULE"]) + "MIDPLANE_NETWORK": copy.deepcopy(ori_config_db["MIDPLANE_NETWORK"]) } #Generate dhcp_server related configuration From 0e6ea4f33de72b1596bbdc0d9006f876d67b7c9f Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Wed, 8 Jan 2025 09:19:28 -0800 Subject: [PATCH 04/10] Added DPU0 entry which is missing in original json file --- ansible/golden_config_db/smartswitch_t1-28-lag.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index 7117fb396cc..e5fcce77a73 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -1,5 +1,8 @@ { "CHASSIS_MODULE": { + "DPU0": { + "admin_status": "down" + }, "DPU1": { "admin_status": "down" }, From 040576694a50f35740de46cc2e9849c2548da44d Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Wed, 8 Jan 2025 21:50:40 -0800 Subject: [PATCH 05/10] removed the DPU table in smartswitch_t1-28-lag.json abd added the DPU table in generate_golden_config_db.py --- .../smartswitch_t1-28-lag.json | 112 +----------------- ansible/library/generate_golden_config_db.py | 54 ++++++++- 2 files changed, 52 insertions(+), 114 deletions(-) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index e5fcce77a73..899fab13895 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -1,114 +1,5 @@ { - "CHASSIS_MODULE": { - "DPU0": { - "admin_status": "down" - }, - "DPU1": { - "admin_status": "down" - }, - "DPU2": { - "admin_status": "down" - }, - "DPU3": { - "admin_status": "down" - }, - "DPU4": { - "admin_status": "down" - }, - "DPU5": { - "admin_status": "down" - }, - "DPU6": { - "admin_status": "down" - }, - "DPU7": { - "admin_status": "down" - } - }, - "DHCP_SERVER_IPV4": { - "bridge-midplane": { - "gateway": "169.254.200.254", - "lease_time": "31536000", - "mode": "PORT", - "netmask": "255.255.255.0", - "state": "enabled" - } - }, - "DHCP_SERVER_IPV4_PORT": { - "bridge-midplane|dpu0": { - "ips": [ - "169.254.200.0" - ] - }, - "bridge-midplane|dpu1": { - "ips": [ - "169.254.200.1" - ] - }, - "bridge-midplane|dpu2": { - "ips": [ - "169.254.200.2" - ] - }, - "bridge-midplane|dpu3": { - "ips": [ - "169.254.200.3" - ] - }, - "bridge-midplane|dpu4": { - "ips": [ - "169.254.200.4" - ] - }, - "bridge-midplane|dpu5": { - "ips": [ - "169.254.200.5" - ] - }, - "bridge-midplane|dpu6": { - "ips": [ - "169.254.200.6" - ] - }, - "bridge-midplane|dpu7": { - "ips": [ - "169.254.200.7" - ] - } - }, - "DPUS": { - "dpu0": { - "midplane_interface": "dpu0" - }, - "dpu1": { - "midplane_interface": "dpu1" - }, - "dpu2": { - "midplane_interface": "dpu2" - }, - "dpu3": { - "midplane_interface": "dpu3" - }, - "dpu4": { - "midplane_interface": "dpu4" - }, - "dpu5": { - "midplane_interface": "dpu5" - }, - "dpu6": { - "midplane_interface": "dpu6" - }, - "dpu7": { - "midplane_interface": "dpu7" - } - }, - "MID_PLANE_BRIDGE": { - "GLOBAL": { - "bridge": "bridge-midplane", - "ip_prefix": "169.254.200.254/24" - } - }, - "GNMI": { + "GNMI": { "certs": { "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer", @@ -129,4 +20,5 @@ "nexthop-vrf": "default" } } + } diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 56affee0b46..0bf4254b860 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -30,7 +30,8 @@ "Cisco-8102-28FH-DPU-O-T1": { "dpu_num": 8, "port_key": "Ethernet-BP{}", - "interface_key": "Ethernet-BP{}|18.{}.202.0/31" + "interface_key": "Ethernet-BP{}|18.{}.202.0/31", + "dpu_key": "dpu{}" } } @@ -126,15 +127,35 @@ def generate_smartswitch_golden_config_db(self): if hwsku not in smartswitch_hwsku_config: return "{}" + if "DPUS" not in ori_config_db: + ori_config_db["DPUS"]= {} + + if "CHASSIS_MODULE" not in ori_config_db: + ori_config_db["CHASSIS_MODULE"]= {} + + if "DHCP_SERVER_IPV4_PORT" not in ori_config_db: + ori_config_db["DHCP_SERVER_IPV4_PORT"] = {} + for i in range(smartswitch_hwsku_config[hwsku]["dpu_num"]): port_key = smartswitch_hwsku_config[hwsku]["port_key"].format(i) interface_key = smartswitch_hwsku_config[hwsku]["interface_key"].format(i, i) + dpu_key = smartswitch_hwsku_config[hwsku]["dpu_key"].format(i) 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] = {} + + ori_config_db["CHASSIS_MODULE"]["DPU{}".format(i)] = {"admin_status": "up"} + if dpu_key not in ori_config_db["DPUS"]: + ori_config_db["DPUS"][dpu_key] = {} + ori_config_db["DPUS"][dpu_key]["midplane_interface"] = dpu_key + + key = "bridge-midplane|dpu{}".format(i) + if key not in ori_config_db["DHCP_SERVER_IPV4_PORT"]: + ori_config_db["DHCP_SERVER_IPV4_PORT"][key] = {} + ori_config_db["DHCP_SERVER_IPV4_PORT"][key]["ips"] = ["169.254.200.{}".format(i)] midplane_network_config = { "midplane_network": { @@ -143,16 +164,41 @@ def generate_smartswitch_golden_config_db(self): } } ori_config_db["MIDPLANE_NETWORK"] = midplane_network_config - + mid_plane_bridge_config = { + "GLOBAL": { + "bridge": "bridge-midplane", + "ip_prefix": "169.254.200.254/24" + } + } + + ori_config_db["MID_PLANE_BRIDGE"] = mid_plane_bridge_config + + dhcp_server_ipv4_config = { + "DHCP_SERVER_IPV4": { + "bridge-midplane": { + "gateway": "169.254.200.254", + "lease_time": "600000000", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" + } + } + } + ori_config_db["DHCP_SERVER_IPV4"] = dhcp_server_ipv4_config["DHCP_SERVER_IPV4"] gold_config_db = { "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]), "FEATURE": copy.deepcopy(ori_config_db["FEATURE"]), "INTERFACE": copy.deepcopy(ori_config_db["INTERFACE"]), "PORT": copy.deepcopy(ori_config_db["PORT"]), - "MIDPLANE_NETWORK": copy.deepcopy(ori_config_db["MIDPLANE_NETWORK"]) + "CHASSIS_MODULE": copy.deepcopy(ori_config_db["CHASSIS_MODULE"]), + "DPUS": copy.deepcopy(ori_config_db["DPUS"]), + "DHCP_SERVER_IPV4_PORT": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4_PORT"]), + "MIDPLANE_NETWORK": copy.deepcopy(ori_config_db["MIDPLANE_NETWORK"]), + "MID_PLANE_BRIDGE": copy.deepcopy(ori_config_db["MID_PLANE_BRIDGE"]), + "DHCP_SERVER_IPV4": copy.deepcopy(ori_config_db["DHCP_SERVER_IPV4"]) } - #Generate dhcp_server related configuration + # Generate dhcp_server related configuration rc, out, err = self.module.run_command("cat {}".format(TEMP_SMARTSWITCH_CONFIG_PATH)) if rc != 0: self.module.fail_json(msg="Failed to get smartswitch config: {}".format(err)) From 0ba9bf8179e0d5f0cc1b2eaace0b2a0db68a7e41 Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Thu, 9 Jan 2025 13:02:39 -0800 Subject: [PATCH 06/10] Fixed flake8 errors in the code --- ansible/library/generate_golden_config_db.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 0bf4254b860..457cce34879 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -128,10 +128,10 @@ def generate_smartswitch_golden_config_db(self): return "{}" if "DPUS" not in ori_config_db: - ori_config_db["DPUS"]= {} + ori_config_db["DPUS"] = {} if "CHASSIS_MODULE" not in ori_config_db: - ori_config_db["CHASSIS_MODULE"]= {} + ori_config_db["CHASSIS_MODULE"] = {} if "DHCP_SERVER_IPV4_PORT" not in ori_config_db: ori_config_db["DHCP_SERVER_IPV4_PORT"] = {} @@ -159,8 +159,8 @@ def generate_smartswitch_golden_config_db(self): midplane_network_config = { "midplane_network": { - "bridge_name": "bridge-midplane", - "bridge_address": "169.254.200.254/24" + "bridge_name": "bridge-midplane", + "bridge_address": "169.254.200.254/24" } } ori_config_db["MIDPLANE_NETWORK"] = midplane_network_config @@ -176,11 +176,11 @@ def generate_smartswitch_golden_config_db(self): dhcp_server_ipv4_config = { "DHCP_SERVER_IPV4": { "bridge-midplane": { - "gateway": "169.254.200.254", - "lease_time": "600000000", - "mode": "PORT", - "netmask": "255.255.255.0", - "state": "enabled" + "gateway": "169.254.200.254", + "lease_time": "600000000", + "mode": "PORT", + "netmask": "255.255.255.0", + "state": "enabled" } } } From 65a3b0e36858f070ee5a76ea892135e0fccbde71 Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Thu, 9 Jan 2025 13:18:43 -0800 Subject: [PATCH 07/10] Fixed flake8 errors in the code --- ansible/library/generate_golden_config_db.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 457cce34879..846da9f5551 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -181,7 +181,7 @@ def generate_smartswitch_golden_config_db(self): "mode": "PORT", "netmask": "255.255.255.0", "state": "enabled" - } + } } } ori_config_db["DHCP_SERVER_IPV4"] = dhcp_server_ipv4_config["DHCP_SERVER_IPV4"] From a61bdf78cc540c76cf36a30ef809c87cbf5f808c Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Thu, 9 Jan 2025 14:14:43 -0800 Subject: [PATCH 08/10] removing trailing-whitespace --- ansible/library/generate_golden_config_db.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index 846da9f5551..db2569e7781 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -161,14 +161,14 @@ def generate_smartswitch_golden_config_db(self): "midplane_network": { "bridge_name": "bridge-midplane", "bridge_address": "169.254.200.254/24" - } - } + } + } ori_config_db["MIDPLANE_NETWORK"] = midplane_network_config mid_plane_bridge_config = { "GLOBAL": { "bridge": "bridge-midplane", "ip_prefix": "169.254.200.254/24" - } + } } ori_config_db["MID_PLANE_BRIDGE"] = mid_plane_bridge_config @@ -182,8 +182,8 @@ def generate_smartswitch_golden_config_db(self): "netmask": "255.255.255.0", "state": "enabled" } - } - } + } + } ori_config_db["DHCP_SERVER_IPV4"] = dhcp_server_ipv4_config["DHCP_SERVER_IPV4"] gold_config_db = { "DEVICE_METADATA": copy.deepcopy(ori_config_db["DEVICE_METADATA"]), From ad3b5323d2531d12093e2e4d8bf07355fd61cc59 Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Thu, 9 Jan 2025 14:28:49 -0800 Subject: [PATCH 09/10] removing trailing-whitespace --- ansible/library/generate_golden_config_db.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ansible/library/generate_golden_config_db.py b/ansible/library/generate_golden_config_db.py index db2569e7781..28f1feb62c4 100644 --- a/ansible/library/generate_golden_config_db.py +++ b/ansible/library/generate_golden_config_db.py @@ -126,13 +126,13 @@ def generate_smartswitch_golden_config_db(self): if hwsku not in smartswitch_hwsku_config: return "{}" - + if "DPUS" not in ori_config_db: ori_config_db["DPUS"] = {} if "CHASSIS_MODULE" not in ori_config_db: ori_config_db["CHASSIS_MODULE"] = {} - + if "DHCP_SERVER_IPV4_PORT" not in ori_config_db: ori_config_db["DHCP_SERVER_IPV4_PORT"] = {} @@ -145,7 +145,7 @@ def generate_smartswitch_golden_config_db(self): ori_config_db["PORT"][port_key]["admin_status"] = "up" ori_config_db["INTERFACE"][port_key] = {} ori_config_db["INTERFACE"][interface_key] = {} - + ori_config_db["CHASSIS_MODULE"]["DPU{}".format(i)] = {"admin_status": "up"} if dpu_key not in ori_config_db["DPUS"]: From 1d50ba0f1f62eb20076b5d8b3f3745afc278b778 Mon Sep 17 00:00:00 2001 From: nnelluri-cisco Date: Mon, 13 Jan 2025 15:10:31 -0800 Subject: [PATCH 10/10] Fixed alignment issue --- ansible/golden_config_db/smartswitch_t1-28-lag.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/golden_config_db/smartswitch_t1-28-lag.json b/ansible/golden_config_db/smartswitch_t1-28-lag.json index 899fab13895..4087c916121 100644 --- a/ansible/golden_config_db/smartswitch_t1-28-lag.json +++ b/ansible/golden_config_db/smartswitch_t1-28-lag.json @@ -1,5 +1,5 @@ { - "GNMI": { + "GNMI": { "certs": { "ca_crt": "/etc/sonic/telemetry/dsmsroot.cer", "server_crt": "/etc/sonic/telemetry/streamingtelemetryserver.cer",