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

addons: vrf: fix check in vrf map initialization when no running vrfs present

Ticket: CM-10178
Review: trivial
Testing: tested with failing testcase in the CM

This patch fixes a check in vrf map initialization code which did
not account for running vrfs correctly. This caused the case where
there were no running vrfs but stale map file to fail.

Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>

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

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
Roopa Prabhu
2016-04-19 15:25:23 -07:00
committed by Nikhil
parent fdf548b091
commit 669b422add
7 changed files with 77 additions and 43 deletions

View File

@@ -1369,8 +1369,7 @@ class bridge(moduleBase):
if attrval:
ifaceobjcurr.update_config_with_status('bridge-vids', attrval, -1)
def _query_check_bridge(self, ifaceobj, ifaceobjcurr,
ifaceobj_getfunc=None):
def _query_check_bridge(self, ifaceobj, ifaceobjcurr, withdefaults):
if not self._is_bridge(ifaceobj):
return
if not self.brctlcmd.bridge_exists(ifaceobj.name):
@@ -1379,6 +1378,9 @@ class bridge(moduleBase):
ifaceattrs = self.dict_key_subset(ifaceobj.config,
self.get_mod_attrs())
#Add default attributes if --with-defaults is set
if withdefaults and 'bridge-stp' not in ifaceattrs:
ifaceattrs.append('bridge-stp')
if not ifaceattrs:
return
try:
@@ -1396,7 +1398,10 @@ class bridge(moduleBase):
# get the corresponding ifaceobj attr
v = ifaceobj.get_attr_value_first(k)
if not v:
continue
if withdefaults and k == 'bridge-stp':
v = 'on' if self.default_stp_on else 'off'
else:
continue
rv = runningattrs.get(k[7:])
if k == 'bridge-mcqv4src':
continue
@@ -1412,14 +1417,14 @@ class bridge(moduleBase):
# special case stp compare because it may
# contain more than one valid values
stp_on_vals = ['on', 'yes']
stp_off_vals = ['off']
stp_off_vals = ['off', 'no']
if ((v in stp_on_vals and rv in stp_on_vals) or
(v in stp_off_vals and rv in stp_off_vals)):
ifaceobjcurr.update_config_with_status('bridge-stp',
v, 0)
rv, 0)
else:
ifaceobjcurr.update_config_with_status('bridge-stp',
v, 1)
rv, 1)
elif k == 'bridge-ports':
# special case ports because it can contain regex or glob
running_port_list = rv.keys() if rv else []
@@ -1601,9 +1606,10 @@ class bridge(moduleBase):
except Exception, e:
self.log_warn('%s: %s' %(ifaceobj.name, str(e)))
def _query_check(self, ifaceobj, ifaceobjcurr, ifaceobj_getfunc=None):
def _query_check(self, ifaceobj, ifaceobjcurr, withdefaults,
ifaceobj_getfunc=None):
if self._is_bridge(ifaceobj):
self._query_check_bridge(ifaceobj, ifaceobjcurr)
self._query_check_bridge(ifaceobj, ifaceobjcurr, withdefaults)
else:
self._query_check_bridge_port(ifaceobj, ifaceobjcurr,
ifaceobj_getfunc)
@@ -1693,7 +1699,7 @@ class bridge(moduleBase):
self.brctlcmd = brctl()
def run(self, ifaceobj, operation, query_ifaceobj=None,
ifaceobj_getfunc=None):
ifaceobj_getfunc=None, **extra_args):
""" run bridge configuration on the interface object passed as
argument. Can create bridge interfaces if they dont exist already
@@ -1718,6 +1724,7 @@ class bridge(moduleBase):
self._flush_running_vidinfo()
if operation == 'query-checkcurr':
op_handler(self, ifaceobj, query_ifaceobj,
extra_args['withdefaults'] if 'withdefaults' in extra_args else False,
ifaceobj_getfunc=ifaceobj_getfunc)
else:
op_handler(self, ifaceobj, ifaceobj_getfunc=ifaceobj_getfunc)