1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

ip batch support for mstp bridges + add support for multiple globs in a

single port expression + cleanup

Ticket: CM-1438
Reviewed By:
Testing Done:

This has left some dead code in. cleanup comming in subsequent patches.
ip batch support is not complete. It currently works only for mstpctl
bridges. more coming ..
This commit is contained in:
roopa
2014-02-27 22:23:03 -08:00
parent 20dd6242f6
commit a690dfae1b
4 changed files with 22 additions and 17 deletions

View File

@@ -30,7 +30,7 @@ verbose=
perf_options() { perf_options() {
# At bootup lets set perfmode # At bootup lets set perfmode
[ -f /var/run/network/ifstatenew ] && echo -n "" && return [ -f /var/tmp/network/ifstatenew ] && echo -n "" && return
echo -n "--perfmode" echo -n "--perfmode"
} }

View File

@@ -111,6 +111,9 @@ class ifupdownMain(ifupdownBase):
self.WITH_DEPENDS = withdepends self.WITH_DEPENDS = withdepends
self.STATEMANAGER_ENABLE = statemanager_enable self.STATEMANAGER_ENABLE = statemanager_enable
self.CACHE = cache self.CACHE = cache
# Can be used to provide hints for caching
self.CACHE_FLAGS = 0x0
self._DELETE_DEPENDENT_IFACES_WITH_NOCONFIG = False self._DELETE_DEPENDENT_IFACES_WITH_NOCONFIG = False
self.ADDONS_ENABLE = addons_enable self.ADDONS_ENABLE = addons_enable
@@ -478,7 +481,8 @@ class ifupdownMain(ifupdownBase):
dryrun=self.DRYRUN, dryrun=self.DRYRUN,
nowait=self.NOWAIT, nowait=self.NOWAIT,
perfmode=self.PERFMODE, perfmode=self.PERFMODE,
cache=self.CACHE) cache=self.CACHE,
cacheflags=self.CACHE_FLAGS)
self.modules[mname] = minstance self.modules[mname] = minstance
if hasattr(minstance, 'get_modinfo'): if hasattr(minstance, 'get_modinfo'):
self.module_attrs[mname] = minstance.get_modinfo() self.module_attrs[mname] = minstance.get_modinfo()

View File

@@ -27,7 +27,6 @@ class ifaceSchedulerFlags():
class ifaceScheduler(): class ifaceScheduler():
""" scheduler functions to schedule configuration of interfaces. """ scheduler functions to schedule configuration of interfaces.
supports scheduling of interfaces serially in plain interface list supports scheduling of interfaces serially in plain interface list
or dependency graph format. or dependency graph format.
""" """
@@ -58,16 +57,17 @@ class ifaceScheduler():
err = 0 err = 0
try: try:
if hasattr(m, 'run'): if hasattr(m, 'run'):
ifupdownobj.logger.debug('%s: %s : running module %s' msg = ('%s: %s : running module %s' %(ifacename, op, mname))
%(ifacename, op, mname))
if op == 'query-checkcurr': if op == 'query-checkcurr':
# Dont check curr if the interface object was # Dont check curr if the interface object was
# auto generated # auto generated
if (ifaceobj.priv_flags & ifupdownobj.NOCONFIG): if (ifaceobj.priv_flags & ifupdownobj.NOCONFIG):
continue continue
ifupdownobj.logger.debug(msg)
m.run(ifaceobj, op, m.run(ifaceobj, op,
query_ifaceobj=ifupdownobj.create_n_save_ifaceobjcurr(ifaceobj)) query_ifaceobj=ifupdownobj.create_n_save_ifaceobjcurr(ifaceobj))
else: else:
ifupdownobj.logger.debug(msg)
m.run(ifaceobj, op) m.run(ifaceobj, op)
except Exception, e: except Exception, e:
err = 1 err = 1
@@ -93,6 +93,12 @@ class ifaceScheduler():
@classmethod @classmethod
def run_iface_ops(cls, ifupdownobj, ifaceobj, ops): def run_iface_ops(cls, ifupdownobj, ifaceobj, ops):
""" Runs all operations on an interface """ """ Runs all operations on an interface """
ifacename = ifaceobj.get_name()
# minor optimization. If operation is 'down', proceed only
# if interface exists in the system
if 'down' in ops[0] and not ifupdownobj.link_exists(ifacename):
ifupdownobj.logger.info('%s: does not exist' %ifacename)
return
cenv=None cenv=None
if ifupdownobj.COMPAT_EXEC_SCRIPTS: if ifupdownobj.COMPAT_EXEC_SCRIPTS:
# For backward compatibility generate env variables # For backward compatibility generate env variables
@@ -109,11 +115,6 @@ class ifaceScheduler():
followdependents=True): followdependents=True):
""" runs interface by traversing all nodes rooted at itself """ """ runs interface by traversing all nodes rooted at itself """
# minor optimization. If operation is 'down', proceed only
# if interface exists in the system
if 'down' in ops[0] and not ifupdownobj.link_exists(ifacename):
ifupdownobj.logger.info('%s: does not exist' %ifacename)
return
# Each ifacename can have a list of iface objects # Each ifacename can have a list of iface objects
ifaceobjs = ifupdownobj.get_ifaceobjs(ifacename) ifaceobjs = ifupdownobj.get_ifaceobjs(ifacename)
@@ -179,8 +180,8 @@ class ifaceScheduler():
pass pass
else: else:
# Dont bring the iface up if children did not come up # Dont bring the iface up if children did not come up
ifaceobj.set_state_n_sttaus(ifaceState.NEW, ifaceobj.set_state_n_status(ifaceState.NEW,
ifacestatus.ERROR) ifaceStatus.ERROR)
raise raise
if order == ifaceSchedulerFlags.POSTORDER: if order == ifaceSchedulerFlags.POSTORDER:
cls.run_iface_ops(ifupdownobj, ifaceobj, ops) cls.run_iface_ops(ifupdownobj, ifaceobj, ops)

View File

@@ -31,7 +31,6 @@ class pickling():
except: except:
raise raise
@classmethod @classmethod
def load(cls, filename): def load(cls, filename):
with open(filename, 'r') as f: with open(filename, 'r') as f:
@@ -40,17 +39,18 @@ class pickling():
except EOFError: break except EOFError: break
except: raise except: raise
class stateManager(): class stateManager():
state_file = '/run/network/ifstatenew' state_dir = '/var/tmp/network/'
state_filename = 'ifstatenew'
def __init__(self): def __init__(self):
self.ifaceobjdict = OrderedDict() self.ifaceobjdict = OrderedDict()
self.logger = logging.getLogger('ifupdown.' + self.logger = logging.getLogger('ifupdown.' +
self.__class__.__name__) self.__class__.__name__)
if not os.path.exists(self.state_dir):
os.mkdir(self.state_dir)
self.state_file = self.state_dir + self.state_filename
def save_ifaceobj(self, ifaceobj): def save_ifaceobj(self, ifaceobj):
if self.ifaceobjdict.get(ifaceobj.get_name()) is None: if self.ifaceobjdict.get(ifaceobj.get_name()) is None: