1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00
Roopa Prabhu 84ca006f82 First phase checkin for new format for vlan aware bridge
Ticket: CM-3346
Reviewed By:
Testing Done: Sanity test + test new bridge format

There are a bunch of open issues with `vlan` interface handling.
Below is the format.

auto swp1
iface swp1
    bridge-access 300
    mstpctl-pathcost 0
    mstpctl-adminedge yes
    mstpctl-autoedge yes
    mstpctl-p2p yes
    mstpctl-bpduguard yes
    mstpctl-treeprio 64
    mstpctl-network yes
    mstpctl-bpdufilter yes

auto swp2
iface swp2
    bridge-vids 301
    bridge-pvid 302
    bridge-pathcost 10
    bridge-priority 10
    bridge-multicast-router 0
    bridge-multicast-fast-leave 1

auto br0
iface br0
    bridge-vlan-aware yes
    bridge-stp on
    bridge-ports swp1 swp2
    bridge-vids 2001

auto br0.2001
iface br0.2001
    address 10.0.14.2
    hwaddress 00:03:00:00:00:12
    address-virtual 00:00:5e:00:01:01 11.0.4.1/24

auto br0.2001
vlan br0.2001
    bridge-igmp-querier-src 172.16.101.1
2014-10-24 10:11:07 -07:00

53 lines
1.4 KiB
Python

#!/usr/bin/python
#
# Copyright 2014 Cumulus Networks, Inc. All rights reserved.
# Author: Roopa Prabhu, roopa@cumulusnetworks.com
#
# utils --
# helper class
#
import os
import fcntl
import re
class utils():
@classmethod
def importName(cls, modulename, name):
""" Import a named object """
try:
module = __import__(modulename, globals(), locals(), [name])
except ImportError:
return None
return getattr(module, name)
@classmethod
def lockFile(cls, lockfile):
try:
fp = os.open(lockfile, os.O_CREAT | os.O_TRUNC | os.O_WRONLY)
fcntl.flock(fp, fcntl.LOCK_EX | fcntl.LOCK_NB)
except IOError:
return False
return True
@classmethod
def parse_iface_range(cls, name):
range_match = re.match("^([\w\.]+)\[([\d]+)-([\d]+)\]", name)
if range_match:
range_groups = range_match.groups()
if range_groups[1] and range_groups[2]:
return (range_groups[0], int(range_groups[1], 10),
int(range_groups[2], 10))
return None
@classmethod
def expand_iface_range(cls, name):
ifacenames = []
iface_range = cls.parse_iface_range(name)
if iface_range:
for i in range(iface_range[1], iface_range[2]):
ifacenames.append('%s-%d' %(iface_range[0], i))
return ifacenames