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

addons: bridge & mstpctl: avoid printing default and port attributes under vlan aware bridge

Ticket: CM-12036
Reviewed By: roopa
Testing Done: used same config from bug

This patch avoids printing port attributes under
vlan-AWARE-bridge on 'ifquer -ra'.

This patch also avoids printing following attributes
on 'ifquer -ra' if not defined:
mstpctl-maxhops
mstpctl-portpathcost
mstpctl-treeportcost

Signed-off-by: Nikhil <nikhil@cumulusnetworks.com>
This commit is contained in:
Nikhil
2016-07-29 13:20:13 -07:00
parent 1b284018d5
commit 0dd2f0d18a
2 changed files with 20 additions and 21 deletions

View File

@@ -1293,6 +1293,7 @@ class bridge(moduleBase):
if stp == 'yes' and userspace_stp:
skip_kernel_stp_attrs = 1
bool2str = {'0': 'no', '1': 'yes'}
# pick all other attributes
for k,v in tmpbridgeattrdict.items():
if not v:
@@ -1304,7 +1305,11 @@ class bridge(moduleBase):
# only include igmp attributes if kernel stp is off
continue
attrname = 'bridge-' + k
if v != self.get_mod_subattr(attrname, 'default'):
mod_default = self.get_mod_subattr(attrname, 'default')
if v != mod_default:
# convert '0|1' running values to 'no|yes'
if v in bool2str.keys() and bool2str[v] == mod_default:
continue
bridgeattrdict[attrname] = [v]
if bridge_vlan_aware:
@@ -1325,7 +1330,8 @@ class bridge(moduleBase):
if skip_kernel_stp_attrs:
return bridgeattrdict
if ports:
# Do this only for vlan-UNAWARE-bridge
if ports and not bridge_vlan_aware:
portconfig = {'bridge-pathcosts' : '',
'bridge-portprios' : ''}
for p, v in ports.items():

View File

@@ -562,7 +562,7 @@ class mstpctl(moduleBase):
except Exception, e:
self.log_error(str(e), ifaceobj)
def _query_running_attrs(self, ifaceobjrunning):
def _query_running_attrs(self, ifaceobjrunning, bridge_vlan_aware=False):
bridgeattrdict = {}
tmpbridgeattrdict = self.mstpctlcmd.get_bridge_attrs(ifaceobjrunning.name)
@@ -576,11 +576,13 @@ class mstpctl(moduleBase):
ports = v.keys()
continue
attrname = 'mstpctl-' + k
if v and v != self.get_mod_subattr(attrname, 'default'):
if (v and v != self.get_mod_subattr(attrname, 'default')
and attrname != 'mstpctl-maxhops'):
bridgeattrdict[attrname] = [v]
ports = self.brctlcmd.get_bridge_ports(ifaceobjrunning.name)
if ports:
# Do this only for vlan-UNAWARE-bridge
if ports and not bridge_vlan_aware:
portconfig = {'mstpctl-portautoedge' : '',
'mstpctl-portbpdufilter' : '',
'mstpctl-portnetwork' : '',
@@ -917,7 +919,8 @@ class mstpctl(moduleBase):
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
ifaceobjrunning.name,
'portautoedge')
if v and v != 'no':
if v and v != self.get_mod_subattr('mstpctl-portautoedge',
'default'):
ifaceobjrunning.update_config('mstpctl-portautoedge', v)
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
@@ -926,20 +929,6 @@ class mstpctl(moduleBase):
if v and v != 'no':
ifaceobjrunning.update_config('mstpctl-portbpdufilter', v)
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
ifaceobjrunning.name,
'portpathcost')
if v and v != self.get_mod_subattr('mstpctl-portpathcost',
'default'):
ifaceobjrunning.update_config('mstpctl-portpathcost', v)
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
ifaceobjrunning.name,
'treeportcost')
if v and v != self.get_mod_subattr('mstpctl-treeportcost',
'default'):
ifaceobjrunning.update_config('mstpctl-treeportcost', v)
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
ifaceobjrunning.name,
'portnetwork')
@@ -1000,8 +989,12 @@ class mstpctl(moduleBase):
# Check if mstp really knows about this bridge
if not self.mstpctlcmd.mstpbridge_exists(ifaceobjrunning.name):
return
bridge_vlan_aware = False
if ifaceobjrunning.get_attr_value_first('bridge-vlan-aware') == 'yes':
bridge_vlan_aware = True
ifaceobjrunning.update_config_dict(self._query_running_attrs(
ifaceobjrunning))
ifaceobjrunning,
bridge_vlan_aware))
def _query_running(self, ifaceobjrunning, **extra_args):
if self.brctlcmd.bridge_exists(ifaceobjrunning.name):