Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summary:New smartswitch DPU config template #16201

Merged
merged 11 commits into from
Jan 22, 2025
107 changes: 1 addition & 106 deletions ansible/golden_config_db/smartswitch_t1-28-lag.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,4 @@
{
"CHASSIS_MODULE": {
"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": {
"certs": {
"ca_crt": "/etc/sonic/telemetry/dsmsroot.cer",
Expand All @@ -126,4 +20,5 @@
"nexthop-vrf": "default"
}
}

}
67 changes: 62 additions & 5 deletions ansible/library/generate_golden_config_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"dpu_num": 8,
"port_key": "Ethernet-BP{}",
"interface_key": "Ethernet-BP{}|18.{}.202.0/31",
"dpu_key": "dpu{}"
}
}

Expand Down Expand Up @@ -74,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 = {
Expand Down Expand Up @@ -126,19 +127,75 @@ def generate_smartswitch_golden_config_db(self):
if hwsku not in smartswitch_hwsku_config:
return "{}"

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 "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"]:
nnelluri-cisco marked this conversation as resolved.
Show resolved Hide resolved
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": {
"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"]),
"FEATURE": copy.deepcopy(ori_config_db["FEATURE"]),
"INTERFACE": copy.deepcopy(ori_config_db["INTERFACE"]),
"PORT": copy.deepcopy(ori_config_db["PORT"])
"PORT": copy.deepcopy(ori_config_db["PORT"]),
"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"]),
nnelluri-cisco marked this conversation as resolved.
Show resolved Hide resolved
"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
Expand Down
Loading