aboutsummaryrefslogtreecommitdiff
path: root/util.py
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-07-24 16:22:37 +0100
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-07-24 16:22:37 +0100
commit857d89f704913ae9b05e33a0eaa2371187346ae9 (patch)
treebd841929d1e9b2715d6c141ce551ed055b214fdf /util.py
parent4797a3ff0d9c65429fa6b86afb7f2238507130ed (diff)
When importing a switch, handle extra port modes gracefully
If we find a switch reporting a port mode that's neither trunk nor access, don't bail out. Instead, configure the port to be "access" and treat it accordingly. For our purposes, access ports are much more common so that's why I've made this choice. Change-Id: I8ab275aa24889ce4e5bb4253370cb74317eebce1
Diffstat (limited to 'util.py')
-rw-r--r--util.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/util.py b/util.py
index 06ba882..d71a84a 100644
--- a/util.py
+++ b/util.py
@@ -745,7 +745,18 @@ class VlanUtil:
# modify once we're done
trunk_ports.append(port_id)
else:
- raise CriticalError("Unrecognised port port mode %s???" % port_mode)
+ # We've found a port mode we don't want, e.g. the
+ # "dynamic auto" on a Cisco Catalyst. Handle that here
+ # - tell the switch to set that port to access and
+ # handle accordingly.
+ s.port_set_mode(port_name, 'access')
+ port_vlans[port_name] = (s.port_get_access_vlan(port_name),)
+ port_vlan_id = db.get_vlan_id_by_tag(port_vlans[port_name][0])
+ port_id = db.create_port(switch_id, port_name,
+ port_vlan_id, port_vlan_id)
+ logging.debug(' Found port in %s mode', port_mode)
+ logging.debug(' Forcing to access mode, VLAN %d', int(port_vlans[port_name][0]))
+ port_mode = "access"
logging.debug(" Added port %s, got port ID %d", port_name, port_id)