mirror of
https://github.com/CumulusNetworks/ifupdown2.git
synced 2024-05-06 15:54:50 +00:00
addons,ifupdown,sbin: adding ifquery --with-defaults option
Ticket: CM-7840 Reviewed By: Roopa Prabhu Testing Done: yes, by installing ifupdown .deb file onto dell-s3000-02 This patch adds a new argument '--with-defaults' to 'ifquery' when 'ifquery --with-defaults' is executed, running states of all interface attributes are compared against respective configured attributes from /etc/network/interfaces file, if configured. Otherwise, compared against default attributes from policy file This patch also: (1) fixes ifquery check failure for bridge-* stp attributes. (2) removes vrf-default-route and vrf-cgroup attributes from ifupdown2 policy and just have the vrf-helper attribute Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
@@ -49,7 +49,7 @@ class ifaceScheduler():
|
||||
cls._SCHED_STATUS = state
|
||||
|
||||
@classmethod
|
||||
def run_iface_op(cls, ifupdownobj, ifaceobj, op, withdefaults=False, cenv=None):
|
||||
def run_iface_op(cls, ifupdownobj, ifaceobj, op, cenv=None):
|
||||
""" Runs sub operation on an interface """
|
||||
ifacename = ifaceobj.name
|
||||
|
||||
@@ -80,11 +80,11 @@ class ifaceScheduler():
|
||||
continue
|
||||
ifupdownobj.logger.debug(msg)
|
||||
m.run(ifaceobj, op, query_ifaceobj,
|
||||
ifaceobj_getfunc=ifupdownobj.get_ifaceobjs, withdefaults=withdefaults)
|
||||
ifaceobj_getfunc=ifupdownobj.get_ifaceobjs)
|
||||
else:
|
||||
ifupdownobj.logger.debug(msg)
|
||||
m.run(ifaceobj, op,
|
||||
ifaceobj_getfunc=ifupdownobj.get_ifaceobjs, withdefaults=withdefaults)
|
||||
ifaceobj_getfunc=ifupdownobj.get_ifaceobjs)
|
||||
except Exception, e:
|
||||
if not ifupdownobj.ignore_error(str(e)):
|
||||
err = 1
|
||||
@@ -117,7 +117,7 @@ class ifaceScheduler():
|
||||
ifupdownobj.log_error(str(e))
|
||||
|
||||
@classmethod
|
||||
def run_iface_list_ops(cls, ifupdownobj, ifaceobjs, ops, withdefaults=False):
|
||||
def run_iface_list_ops(cls, ifupdownobj, ifaceobjs, ops):
|
||||
""" Runs all operations on a list of interface
|
||||
configurations for the same interface
|
||||
"""
|
||||
@@ -151,7 +151,7 @@ class ifaceScheduler():
|
||||
%(ifaceobjs[0].name, str(e)))
|
||||
pass
|
||||
for ifaceobj in ifaceobjs:
|
||||
cls.run_iface_op(ifupdownobj, ifaceobj, op, withdefaults,
|
||||
cls.run_iface_op(ifupdownobj, ifaceobj, op,
|
||||
cenv=ifupdownobj.generate_running_env(ifaceobj, op)
|
||||
if ifupdownobj.config.get('addon_scripts_support',
|
||||
'0') == '1' else None)
|
||||
@@ -212,8 +212,8 @@ class ifaceScheduler():
|
||||
return True
|
||||
|
||||
@classmethod
|
||||
def run_iface_graph(cls, ifupdownobj, ifacename, ops, withdefaults=False,
|
||||
parent=None, order=ifaceSchedulerFlags.POSTORDER,
|
||||
def run_iface_graph(cls, ifupdownobj, ifacename, ops, parent=None,
|
||||
order=ifaceSchedulerFlags.POSTORDER,
|
||||
followdependents=True):
|
||||
""" runs interface by traversing all nodes rooted at itself """
|
||||
|
||||
@@ -235,7 +235,7 @@ class ifaceScheduler():
|
||||
|
||||
# If inorder, run the iface first and then its dependents
|
||||
if order == ifaceSchedulerFlags.INORDER:
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops, False)
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops)
|
||||
|
||||
for ifaceobj in ifaceobjs:
|
||||
# Run lowerifaces or dependents
|
||||
@@ -254,12 +254,11 @@ class ifaceScheduler():
|
||||
if ifupdownobj.is_iface_noconfig(d)]
|
||||
if new_dlist:
|
||||
cls.run_iface_list(ifupdownobj, new_dlist, ops,
|
||||
withdefaults, ifacename, order,
|
||||
followdependents,
|
||||
ifacename, order, followdependents,
|
||||
continueonfailure=False)
|
||||
else:
|
||||
cls.run_iface_list(ifupdownobj, dlist, ops,
|
||||
withdefaults, ifacename, order,
|
||||
ifacename, order,
|
||||
followdependents,
|
||||
continueonfailure=False)
|
||||
except Exception, e:
|
||||
@@ -271,17 +270,18 @@ class ifaceScheduler():
|
||||
ifaceStatus.ERROR)
|
||||
raise
|
||||
if order == ifaceSchedulerFlags.POSTORDER:
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops, withdefaults)
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops)
|
||||
|
||||
@classmethod
|
||||
def run_iface_list(cls, ifupdownobj, ifacenames, ops, withdefaults=False,
|
||||
parent=None, order=ifaceSchedulerFlags.POSTORDER,
|
||||
def run_iface_list(cls, ifupdownobj, ifacenames,
|
||||
ops, parent=None, order=ifaceSchedulerFlags.POSTORDER,
|
||||
followdependents=True, continueonfailure=True):
|
||||
""" Runs interface list """
|
||||
|
||||
for ifacename in ifacenames:
|
||||
try:
|
||||
cls.run_iface_graph(ifupdownobj, ifacename, ops, withdefaults,
|
||||
parent, order, followdependents)
|
||||
cls.run_iface_graph(ifupdownobj, ifacename, ops, parent,
|
||||
order, followdependents)
|
||||
except Exception, e:
|
||||
if continueonfailure:
|
||||
if ifupdownobj.logger.isEnabledFor(logging.DEBUG):
|
||||
@@ -311,7 +311,7 @@ class ifaceScheduler():
|
||||
|
||||
if not skip_root:
|
||||
# run the iface first and then its upperifaces
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops, False)
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops)
|
||||
for ifaceobj in ifaceobjs:
|
||||
# Run upperifaces
|
||||
ulist = ifaceobj.upperifaces
|
||||
@@ -405,7 +405,7 @@ class ifaceScheduler():
|
||||
ifaceobjs = ifupdownobj.get_ifaceobjs(u)
|
||||
if not ifaceobjs:
|
||||
continue
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops, False)
|
||||
cls.run_iface_list_ops(ifupdownobj, ifaceobjs, ops)
|
||||
except Exception, e:
|
||||
if continueonfailure:
|
||||
self.logger.warn('%s' %str(e))
|
||||
@@ -434,7 +434,7 @@ class ifaceScheduler():
|
||||
return ifacenames_sorted
|
||||
|
||||
@classmethod
|
||||
def sched_ifaces(cls, ifupdownobj, ifacenames, ops, withdefaults=False,
|
||||
def sched_ifaces(cls, ifupdownobj, ifacenames, ops,
|
||||
dependency_graph=None, indegrees=None,
|
||||
order=ifaceSchedulerFlags.POSTORDER,
|
||||
followdependents=True, skipupperifaces=False, sort=False):
|
||||
@@ -529,7 +529,7 @@ class ifaceScheduler():
|
||||
run_queue.reverse()
|
||||
|
||||
# run interface list
|
||||
cls.run_iface_list(ifupdownobj, run_queue, ops, withdefaults,
|
||||
cls.run_iface_list(ifupdownobj, run_queue, ops,
|
||||
parent=None, order=order,
|
||||
followdependents=followdependents)
|
||||
if not cls.get_sched_status():
|
||||
|
Reference in New Issue
Block a user