Add a function to get container name by asic ID

This commit is contained in:
Junchao-Mellanox 2024-03-25 08:54:17 +02:00
parent ec57a44b47
commit 691a78ff35
2 changed files with 19 additions and 0 deletions

View File

@ -487,3 +487,16 @@ def get_asic_presence_list():
# This is not multi-asic, all asics should be present.
asics_list = list(range(0, get_num_asics()))
return asics_list
def get_container_name_from_asic_id(service_name, asic_id):
"""Get the container name for a service according to the ASIC ID
Args:
service_name (str): feature/service name
asic_id (int): ASIC ID
Returns:
str: container name of the service in the given ASIC namespace
"""
return '{}{}'.format(service_name, asic_id)

View File

@ -0,0 +1,6 @@
from sonic_py_common import multi_asic
class TestMultiAsic:
def test_get_container_name_from_asic_id(self):
assert multi_asic.get_container_name_from_asic_id('database', 0) == 'database0'