Make vlans of tagged port available through API

In the web interface the VLAN numbers are available for tagged ports but they are not available through the API. This is available for untagged ports, but probably because it’s implemented differently in the database. If it matters, I’m currently testing with Arista EOS devices.

Example of untagged port which returns the VLAN in the ifVlan field:

https://pastebin.com/Aq8T2w5n

Example of tagged port:

config:

interface Ethernet3
description Cust: #SECRET#
switchport trunk allowed vlan 10,20-25,100,114,351
switchport mode trunk

API results of tagged port:
https://pastebin.com/XCnPu0KW

The data is available in the database:

MariaDB [librenms]> SELECT port_id,ifVlan FROM ports WHERE port_id=1497;                        
+---------+--------+
| port_id | ifVlan |
+---------+--------+
|    1497 | 1      |
+---------+--------+
1 row in set (0.00 sec)

MariaDB [librenms]> SELECT port_vlan_id,port_id,vlan FROM ports_vlans WHERE port_id=1497;
+--------------+---------+------+
| port_vlan_id | port_id | vlan |
+--------------+---------+------+
|          661 |    1497 |   10 |
|          668 |    1497 |   20 |
|          675 |    1497 |   21 |
|          694 |    1497 |   22 |
|          713 |    1497 |   23 |
|          719 |    1497 |   24 |
|          725 |    1497 |   25 |
|          757 |    1497 |  100 |
|          763 |    1497 |  114 |
|          784 |    1497 |  351 |
+--------------+---------+------+
10 rows in set (0.00 sec)

Maybe a new function under the ports entrypoint that returns a list of vlans for every port ID?

3 Likes

It would not be under the ports endpoint, it would be under a new vlans endpoint to match our layout (which is based on mibs).