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:
@@ -1293,6 +1293,7 @@ class bridge(moduleBase):
|
|||||||
if stp == 'yes' and userspace_stp:
|
if stp == 'yes' and userspace_stp:
|
||||||
skip_kernel_stp_attrs = 1
|
skip_kernel_stp_attrs = 1
|
||||||
|
|
||||||
|
bool2str = {'0': 'no', '1': 'yes'}
|
||||||
# pick all other attributes
|
# pick all other attributes
|
||||||
for k,v in tmpbridgeattrdict.items():
|
for k,v in tmpbridgeattrdict.items():
|
||||||
if not v:
|
if not v:
|
||||||
@@ -1304,7 +1305,11 @@ class bridge(moduleBase):
|
|||||||
# only include igmp attributes if kernel stp is off
|
# only include igmp attributes if kernel stp is off
|
||||||
continue
|
continue
|
||||||
attrname = 'bridge-' + k
|
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]
|
bridgeattrdict[attrname] = [v]
|
||||||
|
|
||||||
if bridge_vlan_aware:
|
if bridge_vlan_aware:
|
||||||
@@ -1325,7 +1330,8 @@ class bridge(moduleBase):
|
|||||||
if skip_kernel_stp_attrs:
|
if skip_kernel_stp_attrs:
|
||||||
return bridgeattrdict
|
return bridgeattrdict
|
||||||
|
|
||||||
if ports:
|
# Do this only for vlan-UNAWARE-bridge
|
||||||
|
if ports and not bridge_vlan_aware:
|
||||||
portconfig = {'bridge-pathcosts' : '',
|
portconfig = {'bridge-pathcosts' : '',
|
||||||
'bridge-portprios' : ''}
|
'bridge-portprios' : ''}
|
||||||
for p, v in ports.items():
|
for p, v in ports.items():
|
||||||
|
@@ -562,7 +562,7 @@ class mstpctl(moduleBase):
|
|||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.log_error(str(e), ifaceobj)
|
self.log_error(str(e), ifaceobj)
|
||||||
|
|
||||||
def _query_running_attrs(self, ifaceobjrunning):
|
def _query_running_attrs(self, ifaceobjrunning, bridge_vlan_aware=False):
|
||||||
bridgeattrdict = {}
|
bridgeattrdict = {}
|
||||||
|
|
||||||
tmpbridgeattrdict = self.mstpctlcmd.get_bridge_attrs(ifaceobjrunning.name)
|
tmpbridgeattrdict = self.mstpctlcmd.get_bridge_attrs(ifaceobjrunning.name)
|
||||||
@@ -576,11 +576,13 @@ class mstpctl(moduleBase):
|
|||||||
ports = v.keys()
|
ports = v.keys()
|
||||||
continue
|
continue
|
||||||
attrname = 'mstpctl-' + k
|
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]
|
bridgeattrdict[attrname] = [v]
|
||||||
|
|
||||||
ports = self.brctlcmd.get_bridge_ports(ifaceobjrunning.name)
|
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' : '',
|
portconfig = {'mstpctl-portautoedge' : '',
|
||||||
'mstpctl-portbpdufilter' : '',
|
'mstpctl-portbpdufilter' : '',
|
||||||
'mstpctl-portnetwork' : '',
|
'mstpctl-portnetwork' : '',
|
||||||
@@ -917,7 +919,8 @@ class mstpctl(moduleBase):
|
|||||||
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
||||||
ifaceobjrunning.name,
|
ifaceobjrunning.name,
|
||||||
'portautoedge')
|
'portautoedge')
|
||||||
if v and v != 'no':
|
if v and v != self.get_mod_subattr('mstpctl-portautoedge',
|
||||||
|
'default'):
|
||||||
ifaceobjrunning.update_config('mstpctl-portautoedge', v)
|
ifaceobjrunning.update_config('mstpctl-portautoedge', v)
|
||||||
|
|
||||||
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
||||||
@@ -926,20 +929,6 @@ class mstpctl(moduleBase):
|
|||||||
if v and v != 'no':
|
if v and v != 'no':
|
||||||
ifaceobjrunning.update_config('mstpctl-portbpdufilter', v)
|
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,
|
v = self.mstpctlcmd.get_bridgeport_attr(bridgename,
|
||||||
ifaceobjrunning.name,
|
ifaceobjrunning.name,
|
||||||
'portnetwork')
|
'portnetwork')
|
||||||
@@ -1000,8 +989,12 @@ class mstpctl(moduleBase):
|
|||||||
# Check if mstp really knows about this bridge
|
# Check if mstp really knows about this bridge
|
||||||
if not self.mstpctlcmd.mstpbridge_exists(ifaceobjrunning.name):
|
if not self.mstpctlcmd.mstpbridge_exists(ifaceobjrunning.name):
|
||||||
return
|
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.update_config_dict(self._query_running_attrs(
|
||||||
ifaceobjrunning))
|
ifaceobjrunning,
|
||||||
|
bridge_vlan_aware))
|
||||||
|
|
||||||
def _query_running(self, ifaceobjrunning, **extra_args):
|
def _query_running(self, ifaceobjrunning, **extra_args):
|
||||||
if self.brctlcmd.bridge_exists(ifaceobjrunning.name):
|
if self.brctlcmd.bridge_exists(ifaceobjrunning.name):
|
||||||
|
Reference in New Issue
Block a user