Skip to content

Commit 59392a1

Browse files
smaheshmsanthosh-kt
authored andcommitted
[sonic-py-common][multi ASIC] API to get a list of frontend ports (sonic-net#5221)
* [sonic-py-common][multi ASIC] utility to get a list of frontend ports from a given list of ports
1 parent 0cc41b0 commit 59392a1

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
@@ -135,9 +135,8 @@ def get_namespaces_from_linux():
135135
In a multi asic platform, each ASIC is in a Linux Namespace.
136136
This method returns list of all the Namespace present on the device
137137
138-
Note: It is preferable to use this function can be used only
139-
when the config_db is not available.
140-
When configdb is available use get_all_namespaces()
138+
Note: It is preferable to use this function only when config_db is not
139+
available. When configdb is available use get_all_namespaces()
141140
142141
Returns:
143142
List of the namespaces present in the system
@@ -253,6 +252,17 @@ def is_port_internal(port_name, namespace=None):
253252
return False
254253

255254

255+
def get_external_ports(port_names, namespace=None):
256+
external_ports = set()
257+
ports_config = get_port_table(namespace)
258+
for port in port_names:
259+
if port in ports_config:
260+
if (PORT_ROLE not in ports_config[port] or
261+
ports_config[port][PORT_ROLE] == EXTERNAL_PORT):
262+
external_ports.add(port)
263+
return external_ports
264+
265+
256266
def is_port_channel_internal(port_channel, namespace=None):
257267

258268
if not is_multi_asic():

0 commit comments

Comments
 (0)