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

[Mellanox] Fixed sai xml name format bug #19967

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions platform/mellanox/cmis_host_mgmt/cmis_host_mgmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import re
import os
import subprocess
import glob
from pathlib import Path


class CMISHostMgmtActivator:
Expand Down Expand Up @@ -60,7 +62,7 @@ def change_param(param, path, action):
if param == "sai_profile" and not re.search(CMISHostMgmtActivator.PARAMS[param]["disabled_param"], lines):
if not re.search(CMISHostMgmtActivator.PARAMS[param]["enabled_param"], lines):
with open(file_path, 'a') as param_file:
param_file.write(CMISHostMgmtActivator.PARAMS[param]["enabled_param"])
param_file.write(CMISHostMgmtActivator.PARAMS[param]["enabled_param"] + '\n')
return

lines = re.sub(CMISHostMgmtActivator.PARAMS[param]["disabled_param"],
Expand Down Expand Up @@ -137,8 +139,19 @@ def enable(args):

if not CMISHostMgmtActivator.is_spc_supported(sku_num):
print("Error: unsupported platform - feature is supported on SPC3 and higher.")

CMISHostMgmtActivator.PARAMS["sai_xml"]["file_name"] = "sai_{0}.xml".format(sku_num)

sai_profile_file = '{}/{}'.format(sku_path, CMISHostMgmtActivator.PARAMS["sai_profile"]["file_name"])
lines = None
with open(sai_profile_file, 'r') as saiprofile:
lines = saiprofile.read()

sai_xml_path = re.search("SAI_INIT_CONFIG_FILE.*", lines).group()

if sai_xml_path:
sai_xml_name = Path(sai_xml_path).name
CMISHostMgmtActivator.PARAMS["sai_xml"]["file_name"] = sai_xml_name
else:
print("Error: no sai_*.xml file present")

CMISHostMgmtActivator.copy_file(args[0], sku_path)
CMISHostMgmtActivator.copy_file(args[1], sku_path)
Expand Down
Loading