Skip to content

Commit 11ac31c

Browse files
author
vedganes
committed
[multi-asic][cli][chassis-db] Review comments fix 1
- is_voq_supervisor() renamed to is_supervisor() since this API is applicable to non VOQ chassis also - Determination of supervisor card type is done using "supervisor" variable from platfrom_env.conf instead of from asic.conf - Removed changes unrelated to this fix. Signed-off-by: vedganes <[email protected]>
1 parent 4047bf1 commit 11ac31c

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/sonic-py-common/sonic_py_common/device_info.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
NPU_NAME_PREFIX = "asic"
3030
NAMESPACE_PATH_GLOB = "/run/netns/*"
3131
ASIC_CONF_FILENAME = "asic.conf"
32+
PLATFORM_ENV_CONF_FILENAME = "platform_env.conf"
3233
FRONTEND_ASIC_SUB_ROLE = "FrontEnd"
3334
BACKEND_ASIC_SUB_ROLE = "BackEnd"
3435

@@ -164,6 +165,29 @@ def get_asic_conf_file_path():
164165
return None
165166

166167

168+
def get_platform_env_conf_file_path():
169+
"""
170+
Retrieves the path to the PLATFORM ENV conguration file on the device
171+
172+
Returns:
173+
A string containing the path to the PLATFORM ENV conguration file on success,
174+
None on failure
175+
"""
176+
platform_env_conf_path_candidates = []
177+
178+
platform_env_conf_path_candidates.append(os.path.join(CONTAINER_PLATFORM_PATH, PLATFORM_ENV_CONF_FILENAME))
179+
180+
platform = get_platform()
181+
if platform:
182+
platform_env_conf_path_candidates.append(os.path.join(HOST_DEVICE_PATH, platform, PLATFORM_ENV_CONF_FILENAME))
183+
184+
for platform_env_conf_file_path in platform_env_conf_path_candidates:
185+
if os.path.isfile(platform_env_conf_file_path):
186+
return platform_env_conf_file_path
187+
188+
return None
189+
190+
167191
def get_path_to_platform_dir():
168192
"""
169193
Retreives the paths to the device's platform directory
@@ -374,16 +398,16 @@ def is_multi_npu():
374398
return (num_npus > 1)
375399

376400

377-
def is_voq_supervisor():
378-
asic_conf_file_path = get_asic_conf_file_path()
379-
if asic_conf_file_path is None:
401+
def is_supervisor():
402+
platform_env_conf_file_path = get_platform_env_conf_file_path()
403+
if platform_env_conf_file_path is None:
380404
return False
381-
with open(asic_conf_file_path) as asic_conf_file:
382-
for line in asic_conf_file:
405+
with open(platform_env_conf_file_path) as platform_env_conf_file:
406+
for line in platform_env_conf_file:
383407
tokens = line.split('=')
384408
if len(tokens) < 2:
385409
continue
386-
if tokens[0].lower() == 'voq_supervisor':
410+
if tokens[0].lower() == 'supervisor':
387411
val = tokens[1].strip()
388412
if val == '1':
389413
return True

src/sonic-py-common/sonic_py_common/multi_asic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from .device_info import CONTAINER_PLATFORM_PATH
99
from .device_info import HOST_DEVICE_PATH
1010
from .device_info import get_platform
11-
from .device_info import is_voq_supervisor
11+
from .device_info import is_supervisor
1212

1313
ASIC_NAME_PREFIX = 'asic'
1414
NAMESPACE_PATH_GLOB = '/run/netns/*'
@@ -62,7 +62,7 @@ def connect_to_all_dbs_for_ns(namespace=DEFAULT_NAMESPACE):
6262
"""
6363
db = swsscommon.SonicV2Connector(namespace=namespace)
6464
db_list = list(db.get_db_list())
65-
if not is_voq_supervisor():
65+
if not is_supervisor():
6666
try:
6767
db_list.remove('CHASSIS_APP_DB')
6868
db_list.remove('CHASSIS_STATE_DB')

0 commit comments

Comments
 (0)