Skip to content

Commit 389c5fe

Browse files
smaheshmUbuntu
authored and
Ubuntu
committed
[sonic-py-common][multi ASIC] API to get a list of frontend ports (#5221)
* [sonic-py-common][multi ASIC] utility to get a list of frontend ports from a given list of ports
1 parent 649b430 commit 389c5fe

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,8 @@ def get_namespaces_from_linux():
163163
In a multi asic platform, each ASIC is in a Linux Namespace.
164164
This method returns list of all the Namespace present on the device
165165
166-
Note: It is preferable to use this function can be used only
167-
when the config_db is not available.
168-
When configdb is available use get_all_namespaces()
166+
Note: It is preferable to use this function only when config_db is not
167+
available. When configdb is available use get_all_namespaces()
169168
170169
Returns:
171170
List of the namespaces present in the system
@@ -281,6 +280,17 @@ def is_port_internal(port_name, namespace=None):
281280
return False
282281

283282

283+
def get_external_ports(port_names, namespace=None):
284+
external_ports = set()
285+
ports_config = get_port_table(namespace)
286+
for port in port_names:
287+
if port in ports_config:
288+
if (PORT_ROLE not in ports_config[port] or
289+
ports_config[port][PORT_ROLE] == EXTERNAL_PORT):
290+
external_ports.add(port)
291+
return external_ports
292+
293+
284294
def is_port_channel_internal(port_channel, namespace=None):
285295

286296
if not is_multi_asic():

0 commit comments

Comments
 (0)