|
1 | | -#!/usr/bin/env python3 |
| 1 | +#!/usr/bin/python3 |
2 | 2 |
|
3 | 3 | """ |
4 | 4 | ecnconfig is the utility to |
@@ -262,28 +262,35 @@ class EcnQ(object): |
262 | 262 | self.updated_q_table = {} |
263 | 263 |
|
264 | 264 | def gen_ports_key(self): |
265 | | - port_table = self.config_db.get_table(DEVICE_NEIGHBOR_TABLE_NAME) |
266 | | - self.ports_key = list(port_table.keys()) |
267 | | - |
268 | | - # Verify at least one port is available |
269 | | - if len(self.ports_key) == 0: |
270 | | - raise Exception("No active ports detected in table '{}'".format(DEVICE_NEIGHBOR_TABLE_NAME)) |
271 | | - |
272 | | - # In multi-ASIC platforms backend ethernet ports are identified as |
273 | | - # 'Ethernet-BPxy'. Add 1024 to sort backend ports to the end. |
274 | | - self.ports_key.sort( |
275 | | - key = lambda k: int(k[8:]) if "BP" not in k else int(k[11:]) + 1024 |
276 | | - ) |
277 | | - |
278 | 265 | switch_type = device_info.get_localhost_info('switch_type', self.config_db) |
279 | 266 | if switch_type == 'voq' or os.environ.get("UTILITIES_UNIT_TESTING_VOQ", "0") == "1": |
280 | | - ports_key_temp = [] |
281 | | - host_name = device_info.get_localhost_info('hostname', self.config_db) |
282 | | - asic_name = device_info.get_localhost_info('asic_name', self.config_db) |
283 | | - for port_key in self.ports_key: |
284 | | - key = '|'.join([host_name, asic_name, port_key]) |
285 | | - ports_key_temp.append(key) |
286 | | - self.ports_key = ports_key_temp |
| 267 | + system_ports_key= [] |
| 268 | + |
| 269 | + q_table = self.config_db.get_table(QUEUE_TABLE_NAME) |
| 270 | + queue_key = list(q_table.keys()) |
| 271 | + for x in queue_key: |
| 272 | + if os.environ.get("UTILITIES_UNIT_TESTING_VOQ", "0") == "1": |
| 273 | + key = '|'.join([x[0]]) |
| 274 | + else: |
| 275 | + # x[0]->hostname, x[1]->asic, x[2]->port (QUEUE|ixre-egl-board27|asic0|Ethernet80) |
| 276 | + key = '|'.join([x[0], x[1], x[2]]) |
| 277 | + if key not in system_ports_key: |
| 278 | + system_ports_key.append(key) |
| 279 | + |
| 280 | + self.ports_key = system_ports_key |
| 281 | + else: |
| 282 | + port_table = self.config_db.get_table(DEVICE_NEIGHBOR_TABLE_NAME) |
| 283 | + self.ports_key = list(port_table.keys()) |
| 284 | + |
| 285 | + # Verify at least one port is available |
| 286 | + if len(self.ports_key) == 0: |
| 287 | + raise Exception("No active ports detected in table '{}'".format(DEVICE_NEIGHBOR_TABLE_NAME)) |
| 288 | + |
| 289 | + # In multi-ASIC platforms backend ethernet ports are identified as |
| 290 | + # 'Ethernet-BPxy'. Add 1024 to sort backend ports to the end. |
| 291 | + self.ports_key.sort( |
| 292 | + key = lambda k: int(k[8:]) if "BP" not in k else int(k[11:]) + 1024 |
| 293 | + ) |
287 | 294 |
|
288 | 295 | def dump_table_info(self): |
289 | 296 | """ |
|
0 commit comments