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

65 lines
2.1 KiB
Python

#!/usr/bin/python
# This should be pretty simple and might not really even need to exist.
# The key is that we need to call link_create with a type of "dummy"
# since that will translate to 'ip link add loopbackX type dummy'
# The config file should probably just indicate that the type is
# loopback or dummy.
from ifupdown.iface import *
from ifupdownaddons.modulebase import moduleBase
from ifupdownaddons.iproute2 import iproute2
import logging
class loopback(moduleBase):
_modinfo = {'mhelp' : 'configure extra loopback module based on ' +
'dummy device' }
def __init__(self, *args, **kargs):
moduleBase.__init__(self, *args, **kargs)
self.ipcmd = None
def _is_loopback_by_name(self, ifacename):
return 'loop' in ifacename
def _up(self, ifaceobj):
if self._is_loopback_by_name(ifaceobj.name):
self.ipcmd.link_create(ifaceobj.name, 'dummy')
def _down(self, ifaceobj):
if not self.PERFMODE and not self.ipcmd.link_exists(ifaceobj.name):
return
try:
self.ipcmd.link_delete(ifaceobj.name)
except Exception, e:
self.log_warn(str(e))
def _query_check(self, ifaceobj, ifaceobjcurr):
if not self.ipcmd.link_exists(ifaceobj.name):
ifaceobjcurr.status = ifaceStatus.NOTFOUND
return
_run_ops = {'pre-up' : _up,
'post-down' : _down,
'query-checkcurr' : _query_check}
def get_ops(self):
return self._run_ops.keys()
def _init_command_handlers(self):
if not self.ipcmd:
self.ipcmd = iproute2(**self.get_flags())
def run(self, ifaceobj, operation, query_ifaceobj=None, **extra_args):
op_handler = self._run_ops.get(operation)
if not op_handler:
return
if (operation != 'query-running' and
not self._is_loopback_by_name(ifaceobj.name)):
return
self._init_command_handlers()
if operation == 'query-checkcurr':
op_handler(self, ifaceobj, query_ifaceobj)
else:
op_handler(self, ifaceobj)