|
29 | 29 | NPU_NAME_PREFIX = "asic"
|
30 | 30 | NAMESPACE_PATH_GLOB = "/run/netns/*"
|
31 | 31 | ASIC_CONF_FILENAME = "asic.conf"
|
| 32 | +PLATFORM_ENV_CONF_FILENAME = "platform_env.conf" |
32 | 33 | FRONTEND_ASIC_SUB_ROLE = "FrontEnd"
|
33 | 34 | BACKEND_ASIC_SUB_ROLE = "BackEnd"
|
34 | 35 |
|
@@ -164,6 +165,29 @@ def get_asic_conf_file_path():
|
164 | 165 | return None
|
165 | 166 |
|
166 | 167 |
|
| 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 | + |
167 | 191 | def get_path_to_platform_dir():
|
168 | 192 | """
|
169 | 193 | Retreives the paths to the device's platform directory
|
@@ -374,16 +398,16 @@ def is_multi_npu():
|
374 | 398 | return (num_npus > 1)
|
375 | 399 |
|
376 | 400 |
|
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: |
380 | 404 | 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: |
383 | 407 | tokens = line.split('=')
|
384 | 408 | if len(tokens) < 2:
|
385 | 409 | continue
|
386 |
| - if tokens[0].lower() == 'voq_supervisor': |
| 410 | + if tokens[0].lower() == 'supervisor': |
387 | 411 | val = tokens[1].strip()
|
388 | 412 | if val == '1':
|
389 | 413 | return True
|
|
0 commit comments