Skip to content

Commit 79096a7

Browse files
Merge pull request xapi-project#1515 from robhoes/sanibel-lcm-vlan-robustness
[HFX-997] Remove interfaces from bridge before creating VLAN on it
2 parents 29d0aec + e229ed7 commit 79096a7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/InterfaceReconfigureBridge.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ def destroy_vlan(pif):
171171
log("bring_down_interface: %s is a VLAN" % interface)
172172
netdev_down(interface)
173173

174+
# Robustness enhancement: ensure there are no other VLANs in the bridge
175+
bridge = pif_bridge_name(pif)
176+
try:
177+
brifs = os.listdir(root_prefix() + "/sys/class/net/%s/brif" % bridge)
178+
brifs = filter(lambda name: name[:3] == 'eth' or name[:4] == 'bond', brifs)
179+
except:
180+
brifs = []
181+
log("Removing these non-VIF interfaces found on the bridge: %s" % ", ".join(brifs))
182+
for device in brifs:
183+
run_command(["/usr/sbin/brctl", "delif", bridge, device])
184+
netdev_down(device)
185+
174186
if destroy:
175187
destroy_vlan(pif)
176188
destroy_bridge(pif)

0 commit comments

Comments
 (0)