self.WITH_DEPENDS = withdepends
self.STATEMANAGER_ENABLE = statemanager_enable
self.CACHE = cache
+
+ # Can be used to provide hints for caching
+ self.CACHE_FLAGS = 0x0
self._DELETE_DEPENDENT_IFACES_WITH_NOCONFIG = False
self.ADDONS_ENABLE = addons_enable
dryrun=self.DRYRUN,
nowait=self.NOWAIT,
perfmode=self.PERFMODE,
- cache=self.CACHE)
+ cache=self.CACHE,
+ cacheflags=self.CACHE_FLAGS)
self.modules[mname] = minstance
if hasattr(minstance, 'get_modinfo'):
self.module_attrs[mname] = minstance.get_modinfo()
class ifaceScheduler():
""" scheduler functions to schedule configuration of interfaces.
-
supports scheduling of interfaces serially in plain interface list
or dependency graph format.
"""
err = 0
try:
if hasattr(m, 'run'):
- ifupdownobj.logger.debug('%s: %s : running module %s'
- %(ifacename, op, mname))
+ msg = ('%s: %s : running module %s' %(ifacename, op, mname))
if op == 'query-checkcurr':
# Dont check curr if the interface object was
# auto generated
if (ifaceobj.priv_flags & ifupdownobj.NOCONFIG):
continue
+ ifupdownobj.logger.debug(msg)
m.run(ifaceobj, op,
query_ifaceobj=ifupdownobj.create_n_save_ifaceobjcurr(ifaceobj))
else:
+ ifupdownobj.logger.debug(msg)
m.run(ifaceobj, op)
except Exception, e:
err = 1
@classmethod
def run_iface_ops(cls, ifupdownobj, ifaceobj, ops):
""" 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
if ifupdownobj.COMPAT_EXEC_SCRIPTS:
# For backward compatibility generate env variables
followdependents=True):
""" 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
ifaceobjs = ifupdownobj.get_ifaceobjs(ifacename)
pass
else:
# Dont bring the iface up if children did not come up
- ifaceobj.set_state_n_sttaus(ifaceState.NEW,
- ifacestatus.ERROR)
+ ifaceobj.set_state_n_status(ifaceState.NEW,
+ ifaceStatus.ERROR)
raise
if order == ifaceSchedulerFlags.POSTORDER:
cls.run_iface_ops(ifupdownobj, ifaceobj, ops)
except:
raise
-
@classmethod
def load(cls, filename):
with open(filename, 'r') as f:
except EOFError: break
except: raise
-
-
class stateManager():
- state_file = '/run/network/ifstatenew'
-
+ state_dir = '/var/tmp/network/'
+ state_filename = 'ifstatenew'
def __init__(self):
self.ifaceobjdict = OrderedDict()
self.logger = logging.getLogger('ifupdown.' +
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):
if self.ifaceobjdict.get(ifaceobj.get_name()) is None: