Add a function to get container name by asic ID
This commit is contained in:
parent
ec57a44b47
commit
691a78ff35
@ -487,3 +487,16 @@ def get_asic_presence_list():
|
|||||||
# This is not multi-asic, all asics should be present.
|
# This is not multi-asic, all asics should be present.
|
||||||
asics_list = list(range(0, get_num_asics()))
|
asics_list = list(range(0, get_num_asics()))
|
||||||
return asics_list
|
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)
|
||||||
|
6
src/sonic-py-common/tests/multi_asic_test.py
Normal file
6
src/sonic-py-common/tests/multi_asic_test.py
Normal 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'
|
Reference in New Issue
Block a user