aboutsummaryrefslogtreecommitdiff
path: root/db/db.py
diff options
context:
space:
mode:
Diffstat (limited to 'db/db.py')
-rw-r--r--db/db.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/db.py b/db/db.py
index c258a5e..4fc9444 100644
--- a/db/db.py
+++ b/db/db.py
@@ -549,6 +549,18 @@ class VlanDB:
def get_current_vlan_id_by_port(self, port_id):
return self._get_element("current_vlan_id", "port", "port_id", int(port_id))
+ # Simple lookup: look up a port by ID, and return the mode of that port.
+ #
+ # Returns None on failure.
+ def get_port_mode(self, port_id):
+ is_trunk = self._get_element("is_trunk", "port", "port_id", int(port_id))
+ if is_trunk is not None:
+ if is_trunk:
+ return "trunk"
+ else:
+ return "access"
+ return None
+
# Simple lookup: look up a port by ID, and return the base VLAN
# id of that port.
#